Trait fred::interfaces::KeysInterface

source ·
pub trait KeysInterface: ClientLike + Sized {
Show 35 methods // Provided methods fn watch<K>(&self, keys: K) -> impl Future<Output = RedisResult<()>> where K: Into<MultipleKeys> { ... } fn unwatch(&self) -> impl Future<Output = RedisResult<()>> { ... } fn randomkey<R>(&self) -> impl Future<Output = RedisResult<R>> where R: FromRedis { ... } fn copy<R, S, D>( &self, source: S, destination: D, db: Option<u8>, replace: bool, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, S: Into<RedisKey>, D: Into<RedisKey> { ... } fn dump<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn restore<R, K>( &self, key: K, ttl: i64, serialized: RedisValue, replace: bool, absttl: bool, idletime: Option<i64>, frequency: Option<i64>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn set<R, K, V>( &self, key: K, value: V, expire: Option<Expiration>, options: Option<SetOptions>, get: bool, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, V: TryInto<RedisValue>, V::Error: Into<RedisError> { ... } fn get<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn getrange<R, K>( &self, key: K, start: usize, end: usize, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn setrange<R, K, V>( &self, key: K, offset: u32, value: V, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, V: TryInto<RedisValue>, V::Error: Into<RedisError> { ... } fn getset<R, K, V>( &self, key: K, value: V, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, V: TryInto<RedisValue>, V::Error: Into<RedisError> { ... } fn getdel<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn strlen<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn del<R, K>(&self, keys: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<MultipleKeys> { ... } fn unlink<R, K>(&self, keys: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<MultipleKeys> { ... } fn rename<R, S, D>( &self, source: S, destination: D, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, S: Into<RedisKey>, D: Into<RedisKey> { ... } fn renamenx<R, S, D>( &self, source: S, destination: D, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, S: Into<RedisKey>, D: Into<RedisKey> { ... } fn append<R, K, V>( &self, key: K, value: V, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, V: TryInto<RedisValue>, V::Error: Into<RedisError> { ... } fn mget<R, K>(&self, keys: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<MultipleKeys> { ... } fn mset<V>(&self, values: V) -> impl Future<Output = RedisResult<()>> where V: TryInto<RedisMap>, V::Error: Into<RedisError> { ... } fn msetnx<R, V>(&self, values: V) -> impl Future<Output = RedisResult<R>> where R: FromRedis, V: TryInto<RedisMap>, V::Error: Into<RedisError> { ... } fn incr<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn incr_by<R, K>( &self, key: K, val: i64, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn incr_by_float<R, K>( &self, key: K, val: f64, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn decr<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn decr_by<R, K>( &self, key: K, val: i64, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn ttl<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn pttl<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn persist<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn expire<R, K>( &self, key: K, seconds: i64, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn expire_at<R, K>( &self, key: K, timestamp: i64, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn pexpire<R, K>( &self, key: K, milliseconds: i64, options: Option<ExpireOptions>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn pexpire_at<R, K>( &self, key: K, timestamp: i64, options: Option<ExpireOptions>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey> { ... } fn exists<R, K>(&self, keys: K) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<MultipleKeys> { ... } fn lcs<R, K1, K2>( &self, key1: K1, key2: K2, len: bool, idx: bool, minmatchlen: Option<i64>, withmatchlen: bool, ) -> impl Future<Output = Result<R, RedisError>> where R: FromRedis, K1: Into<RedisKey>, K2: Into<RedisKey> { ... }
}
Available on crate feature i-keys only.
Expand description

Functions that implement the generic keys interface.

Provided Methods§

source

fn watch<K>(&self, keys: K) -> impl Future<Output = RedisResult<()>>
where K: Into<MultipleKeys>,

Marks the given keys to be watched for conditional execution of a transaction.

https://redis.io/commands/watch

source

fn unwatch(&self) -> impl Future<Output = RedisResult<()>>

Flushes all the previously watched keys for a transaction.

https://redis.io/commands/unwatch

source

fn randomkey<R>(&self) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,

Return a random key from the currently selected database.

https://redis.io/commands/randomkey

source

fn copy<R, S, D>( &self, source: S, destination: D, db: Option<u8>, replace: bool, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, S: Into<RedisKey>, D: Into<RedisKey>,

This command copies the value stored at the source key to the destination key.

https://redis.io/commands/copy

source

fn dump<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Serialize the value stored at key in a Redis-specific format and return it as bulk string.

https://redis.io/commands/dump

source

fn restore<R, K>( &self, key: K, ttl: i64, serialized: RedisValue, replace: bool, absttl: bool, idletime: Option<i64>, frequency: Option<i64>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Create a key associated with a value that is obtained by deserializing the provided serialized value

https://redis.io/commands/restore

source

fn set<R, K, V>( &self, key: K, value: V, expire: Option<Expiration>, options: Option<SetOptions>, get: bool, ) -> impl Future<Output = RedisResult<R>>

Set a value with optional NX|XX, EX|PX|EXAT|PXAT|KEEPTTL, and GET arguments.

Note: the get flag was added in 6.2.0. Setting it as false works with Redis versions <=6.2.0.

https://redis.io/commands/set

source

fn get<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Read a value from the server.

https://redis.io/commands/get

source

fn getrange<R, K>( &self, key: K, start: usize, end: usize, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Returns the substring of the string value stored at key with offsets start and end (both inclusive).

Note: Command formerly called SUBSTR in Redis verison <=2.0.

https://redis.io/commands/getrange

source

fn setrange<R, K, V>( &self, key: K, offset: u32, value: V, ) -> impl Future<Output = RedisResult<R>>

Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value.

https://redis.io/commands/setrange

source

fn getset<R, K, V>( &self, key: K, value: V, ) -> impl Future<Output = RedisResult<R>>

Atomically sets key to value and returns the old value stored at key.

Returns an error if key does not hold string value. Returns nil if key does not exist.

https://redis.io/commands/getset

source

fn getdel<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Get the value of key and delete the key. This command is similar to GET, except for the fact that it also deletes the key on success (if and only if the key’s value type is a string).

https://redis.io/commands/getdel

source

fn strlen<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Returns the length of the string value stored at key. An error is returned when key holds a non-string value.

https://redis.io/commands/strlen

source

fn del<R, K>(&self, keys: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<MultipleKeys>,

Removes the specified keys. A key is ignored if it does not exist.

Returns the number of keys removed.

https://redis.io/commands/del

Unlinks the specified keys. A key is ignored if it does not exist

Returns the number of keys removed.

https://redis.io/commands/del

source

fn rename<R, S, D>( &self, source: S, destination: D, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, S: Into<RedisKey>, D: Into<RedisKey>,

Renames source key to destination.

Returns an error when source does not exist. If destination exists, it gets overwritten.

https://redis.io/commands/rename

source

fn renamenx<R, S, D>( &self, source: S, destination: D, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, S: Into<RedisKey>, D: Into<RedisKey>,

Renames source key to destination if destination does not yet exist.

Returns an error when source does not exist.

https://redis.io/commands/renamenx

source

fn append<R, K, V>( &self, key: K, value: V, ) -> impl Future<Output = RedisResult<R>>

Append value to key if it’s a string.

https://redis.io/commands/append/

source

fn mget<R, K>(&self, keys: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<MultipleKeys>,

Returns the values of all specified keys. For every key that does not hold a string value or does not exist, the special value nil is returned.

https://redis.io/commands/mget

source

fn mset<V>(&self, values: V) -> impl Future<Output = RedisResult<()>>

Sets the given keys to their respective values.

https://redis.io/commands/mset

source

fn msetnx<R, V>(&self, values: V) -> impl Future<Output = RedisResult<R>>

Sets the given keys to their respective values. MSETNX will not perform any operation at all even if just a single key already exists.

https://redis.io/commands/msetnx

source

fn incr<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation.

Returns an error if the value at key is of the wrong type.

https://redis.io/commands/incr

source

fn incr_by<R, K>( &self, key: K, val: i64, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Increments the number stored at key by val. If the key does not exist, it is set to 0 before performing the operation.

Returns an error if the value at key is of the wrong type.

https://redis.io/commands/incrby

source

fn incr_by_float<R, K>( &self, key: K, val: f64, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Increment the string representing a floating point number stored at key by val. If the key does not exist, it is set to 0 before performing the operation.

Returns an error if key value is the wrong type or if the current value cannot be parsed as a floating point value.

https://redis.io/commands/incrbyfloat

source

fn decr<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Decrements the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation.

Returns an error if the key contains a value of the wrong type.

https://redis.io/commands/decr

source

fn decr_by<R, K>( &self, key: K, val: i64, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Decrements the number stored at key by val. If the key does not exist, it is set to 0 before performing the operation.

Returns an error if the key contains a value of the wrong type.

https://redis.io/commands/decrby

source

fn ttl<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Returns the remaining time to live of a key that has a timeout, in seconds.

https://redis.io/commands/ttl

source

fn pttl<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Returns the remaining time to live of a key that has a timeout, in milliseconds.

https://redis.io/commands/pttl

source

fn persist<R, K>(&self, key: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Remove the existing timeout on a key, turning the key from volatile (a key with an expiration) to persistent (a key that will never expire as no timeout is associated).

Returns a boolean value describing whether the timeout was removed.

https://redis.io/commands/persist

source

fn expire<R, K>( &self, key: K, seconds: i64, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Set a timeout on key. After the timeout has expired, the key will be automatically deleted.

https://redis.io/commands/expire

source

fn expire_at<R, K>( &self, key: K, timestamp: i64, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

Set a timeout on a key based on a UNIX timestamp.

https://redis.io/commands/expireat

source

fn pexpire<R, K>( &self, key: K, milliseconds: i64, options: Option<ExpireOptions>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

This command works exactly like EXPIRE but the time to live of the key is specified in milliseconds instead of seconds.

https://redis.io/docs/latest/commands/pexpire/

source

fn pexpire_at<R, K>( &self, key: K, timestamp: i64, options: Option<ExpireOptions>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>,

PEXPIREAT has the same effect and semantic as EXPIREAT, but the Unix time at which the key will expire is specified in milliseconds instead of seconds.

https://redis.io/docs/latest/commands/pexpireat/

source

fn exists<R, K>(&self, keys: K) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<MultipleKeys>,

Returns number of keys that exist from the keys arguments.

https://redis.io/commands/exists

source

fn lcs<R, K1, K2>( &self, key1: K1, key2: K2, len: bool, idx: bool, minmatchlen: Option<i64>, withmatchlen: bool, ) -> impl Future<Output = Result<R, RedisError>>
where R: FromRedis, K1: Into<RedisKey>, K2: Into<RedisKey>,

Runs the longest common subsequence algorithm on two keys.

https://redis.io/commands/lcs/

Object Safety§

This trait is not object safe.

Implementors§