pub struct IncrexOptions<T> { /* private fields */ }Expand description
Options for the INCREX command.
T is the type of the increment and of the LBOUND/UBOUND bounds.
It matches the increment passed to increx.
(e.g. IncrexOptions<i64> for an i64 increment, IncrexOptions<f64> for an f64 one).
§Example
use redis::{Commands, RedisResult, IncrexOptions, IncrexResult, Expiry};
fn bump(con: &mut redis::Connection) -> RedisResult<IncrexResult> {
let opts = IncrexOptions::default()
.saturate()
.upper_bound(100)
.with_expiration(Expiry::EX(60));
con.increx("counter", 5, opts)
}Implementations§
Source§impl<T: ToSingleRedisArg> IncrexOptions<T>
impl<T: ToSingleRedisArg> IncrexOptions<T>
Sourcepub fn saturate(self) -> Self
pub fn saturate(self) -> Self
Instead of rejecting an out-of-bounds operation, clamp the result to the specified bound or to the type’s limit when no explicit bound is set.
Sourcepub fn lower_bound(self, lower_bound: T) -> Self
pub fn lower_bound(self, lower_bound: T) -> Self
Set the lower bound for the operation (LBOUND).
Sourcepub fn upper_bound(self, upper_bound: T) -> Self
pub fn upper_bound(self, upper_bound: T) -> Self
Set the upper bound for the operation (UBOUND).
Sourcepub fn with_expiration(self, expiration: Expiry) -> Self
pub fn with_expiration(self, expiration: Expiry) -> Self
Set the expiration to apply to the key (EX/PX/EXAT/PXAT/PERSIST).
Sourcepub fn enx(self) -> Self
pub fn enx(self) -> Self
Only apply the expiration if the key currently has no TTL (ENX).
Requires an expiration other than Expiry::PERSIST to be set.
The server rejects ENX combined with PERSIST.
Trait Implementations§
Source§impl<T: Clone> Clone for IncrexOptions<T>
impl<T: Clone> Clone for IncrexOptions<T>
Source§fn clone(&self) -> IncrexOptions<T>
fn clone(&self) -> IncrexOptions<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Default> Default for IncrexOptions<T>
impl<T: Default> Default for IncrexOptions<T>
Source§fn default() -> IncrexOptions<T>
fn default() -> IncrexOptions<T>
Returns the “default value” for a type. Read more
Source§impl<T: ToRedisArgs> ToRedisArgs for IncrexOptions<T>
impl<T: ToRedisArgs> ToRedisArgs for IncrexOptions<T>
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 num_of_args(&self) -> usize
fn num_of_args(&self) -> usize
Returns the number of arguments this value will generate. Read more
Auto Trait Implementations§
impl<T> Freeze for IncrexOptions<T>
impl<T> RefUnwindSafe for IncrexOptions<T>where
Option<T>: RefUnwindSafe,
impl<T> Send for IncrexOptions<T>
impl<T> Sync for IncrexOptions<T>
impl<T> Unpin for IncrexOptions<T>
impl<T> UnsafeUnpin for IncrexOptions<T>where
Option<T>: UnsafeUnpin,
impl<T> UnwindSafe for IncrexOptions<T>where
Option<T>: UnwindSafe,
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