pub struct SetOptions { /* private fields */ }
Expand description
Options for the SET command
§Example
use redis::{Commands, RedisResult, SetOptions, SetExpiry, ExistenceCheck};
fn set_key_value(
con: &mut redis::Connection,
key: &str,
value: &str,
) -> RedisResult<Vec<usize>> {
let opts = SetOptions::default()
.conditional_set(ExistenceCheck::NX)
.get(true)
.with_expiration(SetExpiry::EX(60));
con.set_options(key, value, opts)
}
Implementations§
source§impl SetOptions
impl SetOptions
sourcepub fn conditional_set(self, existence_check: ExistenceCheck) -> Self
pub fn conditional_set(self, existence_check: ExistenceCheck) -> Self
Set the existence check for the SET command
sourcepub fn with_expiration(self, expiration: SetExpiry) -> Self
pub fn with_expiration(self, expiration: SetExpiry) -> Self
Set the expiration for the SET command
Trait Implementations§
source§impl Clone for SetOptions
impl Clone for SetOptions
source§fn clone(&self) -> SetOptions
fn clone(&self) -> SetOptions
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Default for SetOptions
impl Default for SetOptions
source§fn default() -> SetOptions
fn default() -> SetOptions
Returns the “default value” for a type. Read more
source§impl ToRedisArgs for SetOptions
impl ToRedisArgs for SetOptions
source§fn write_redis_args<W>(&self, out: &mut W)where
W: ?Sized + RedisWrite,
fn write_redis_args<W>(&self, out: &mut W)where
W: ?Sized + RedisWrite,
This writes the value into a vector of bytes. Each item
is a single argument. Most items generate a single item. Read more
source§fn to_redis_args(&self) -> Vec<Vec<u8>>
fn to_redis_args(&self) -> Vec<Vec<u8>>
This converts the value into a vector of bytes. Each item
is a single argument. Most items generate a vector of a
single item. Read more
source§fn describe_numeric_behavior(&self) -> NumericBehavior
fn describe_numeric_behavior(&self) -> NumericBehavior
Returns an information about the contained value with regards
to it’s numeric behavior in a redis context. This is used in
some high level concepts to switch between different implementations
of redis functions (for instance
INCR
vs INCRBYFLOAT
).source§fn is_single_arg(&self) -> bool
fn is_single_arg(&self) -> bool
Returns an indiciation if the value contained is exactly one
argument. It returns false if it’s zero or more than one. This
is used in some high level functions to intelligently switch
between
GET
and MGET
variants.impl Copy for SetOptions
Auto Trait Implementations§
impl Freeze for SetOptions
impl RefUnwindSafe for SetOptions
impl Send for SetOptions
impl Sync for SetOptions
impl Unpin for SetOptions
impl UnwindSafe for SetOptions
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)