[][src]Struct fred::RedisClient

pub struct RedisClient { /* fields omitted */ }

A Redis client.

Methods

impl RedisClient[src]

pub fn new(config: RedisConfig) -> RedisClient[src]

Create a new RedisClient instance.

pub fn quit(self) -> Box<dyn Future<Item = Self, Error = RedisError>>[src]

Close the connection to the Redis server. The returned future resolves when the command has been written to the socket, not when the connection has been fully closed. Some time after this future resolves the future returned by connect or connect_with_policy will resolve, and that indicates that the connection has been fully closed.

This function will also close all error, message, and reconnection event streams.

Note: This function will immediately succeed if the client is already disconnected. This is to allow quit to be used a means to break out from reconnect logic. If this function is called while the client is waiting to attempt to reconnect then when it next wakes up to try to reconnect it will instead break out with a RedisErrorKind::Canceled error. This in turn will resolve the future returned by connect or connect_with_policy some time later.

pub fn state(&self) -> ClientState[src]

Read the state of the underlying connection.

pub fn read_latency_metrics(&self) -> LatencyMetrics[src]

Read latency metrics across all commands.

pub fn take_latency_metrics(&self) -> LatencyMetrics[src]

Read and consume latency metrics, resetting their values afterwards.

pub fn read_size_metrics(&self) -> SizeMetrics[src]

Read payload size metrics across all commands.

pub fn take_size_metrics(&self) -> SizeMetrics[src]

Read and consume payload size metrics, resetting their values afterwards.

pub fn connect(&self, handle: &Handle) -> ConnectionFuture[src]

Connect to the Redis server. The returned future will resolve when the connection to the Redis server has been fully closed by both ends.

The on_connect function can be used to be notified when the client first successfully connects.

pub fn connect_with_policy(
    &self,
    handle: &Handle,
    policy: ReconnectPolicy
) -> Box<dyn Future<Item = (), Error = RedisError>>
[src]

Connect to the Redis server with a ReconnectPolicy to apply if the connection closes due to an error. The returned future will resolve when max_attempts is reached on the ReconnectPolicy.

Use the on_error and on_reconnect functions to be notified when the connection dies or successfully reconnects. Note that when the client automatically reconnects it will not re-select the previously selected database, nor will it re-subscribe to any pubsub channels. Use on_reconnect to implement that functionality if needed.

Additionally, on_connect can be used to be notified when the client first successfully connects, since sometimes some special initialization is needed upon first connecting.

pub fn on_reconnect(&self) -> Box<dyn Stream<Item = Self, Error = RedisError>>[src]

Listen for successful reconnection notifications. When using a config with a ReconnectPolicy the future returned by connect_with_policy will not resolve until max_attempts is reached, potentially running forever if set to 0. This function can be used to receive notifications whenever the client successfully reconnects in order to select the right database again, re-subscribe to channels, etc. A reconnection event is also triggered upon first connecting.

pub fn on_connect(&self) -> Box<dyn Future<Item = Self, Error = RedisError>>[src]

Returns a future that resolves when the client connects to the server. If the client is already connected this future will resolve immediately.

This can be used with on_reconnect to separate initialization logic that needs to occur only on the next connection vs subsequent connections.

pub fn on_error(&self) -> Box<dyn Stream<Item = RedisError, Error = RedisError>>[src]

Listen for protocol and connection errors. This stream can be used to more intelligently handle errors that may not appear in the request-response cycle, and so cannot be handled by response futures.

Similar to on_message, this function does not need to be called again if the connection goes down.

pub fn on_message(
    &self
) -> Box<dyn Stream<Item = (String, RedisValue), Error = RedisError>>
[src]

Listen for (channel, message) tuples on the PubSub interface.

If the connection to the Redis server goes down for any reason this function does not need to be called again. Messages will start appearing on the original stream after subscribe is called again.

pub fn is_clustered(&self) -> bool[src]

Whether or not the client is using a clustered Redis deployment.

pub fn split_cluster(
    &self,
    handle: &Handle
) -> Box<dyn Future<Item = Vec<(RedisClient, RedisConfig)>, Error = RedisError>>
[src]

Split a clustered redis client into a list of centralized clients for each master node in the cluster.

This is an expensive operation and should not be used frequently, if possible.

pub fn select(self, db: u8) -> Box<dyn Future<Item = Self, Error = RedisError>>[src]

Select the database this client should use.

https://redis.io/commands/select

pub fn info(
    self,
    section: Option<InfoKind>
) -> Box<dyn Future<Item = (Self, String), Error = RedisError>>
[src]

Read info about the Redis server.

https://redis.io/commands/info

pub fn ping(self) -> Box<dyn Future<Item = (Self, String), Error = RedisError>>[src]

Ping the Redis server.

https://redis.io/commands/ping

pub fn subscribe<T: Into<String>>(
    self,
    channel: T
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Subscribe to a channel on the PubSub interface. Any messages received before on_message is called will be discarded, so it's usually best to call on_message before calling subscribe for the first time. The usize returned here is the number of channels to which the client is currently subscribed.

https://redis.io/commands/subscribe

pub fn unsubscribe<T: Into<String>>(
    self,
    channel: T
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Unsubscribe from a channel on the PubSub interface.

https://redis.io/commands/unsubscribe

pub fn publish<T: Into<String>, V: Into<RedisValue>>(
    self,
    channel: T,
    message: V
) -> Box<dyn Future<Item = (Self, i64), Error = RedisError>>
[src]

Publish a message on the PubSub interface, returning the number of clients that received the message.

https://redis.io/commands/publish

pub fn get<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, Option<RedisValue>), Error = RedisError>>
[src]

Read a value from Redis at key.

https://redis.io/commands/get

pub fn set<K: Into<RedisKey>, V: Into<RedisValue>>(
    self,
    key: K,
    value: V,
    expire: Option<Expiration>,
    options: Option<SetOptions>
) -> Box<dyn Future<Item = (Self, bool), Error = RedisError>>
[src]

Set a value at key with optional NX|XX and EX|PX arguments. The bool returned by this function describes whether or not the key was set due to any NX|XX options.

https://redis.io/commands/set

pub fn auth<V: Into<String>>(
    self,
    value: V
) -> Box<dyn Future<Item = (Self, String), Error = RedisError>>
[src]

Request for authentication in a password-protected Redis server. Returns ok if successful.

https://redis.io/commands/auth

pub fn bgrewriteaof(
    self
) -> Box<dyn Future<Item = (Self, String), Error = RedisError>>
[src]

Instruct Redis to start an Append Only File rewrite process. Returns ok.

https://redis.io/commands/bgrewriteaof

pub fn bgsave(
    self
) -> Box<dyn Future<Item = (Self, String), Error = RedisError>>
[src]

Save the DB in background. Returns ok.

https://redis.io/commands/bgsave

pub fn client_list(
    self
) -> Box<dyn Future<Item = (Self, String), Error = RedisError>>
[src]

Returns information and statistics about the client connections.

https://redis.io/commands/client-list

pub fn client_getname(
    self
) -> Box<dyn Future<Item = (Self, Option<String>), Error = RedisError>>
[src]

Returns the name of the current connection as a string, or None if no name is set.

https://redis.io/commands/client-getname

pub fn client_setname<V: Into<String>>(
    self,
    name: V
) -> Box<dyn Future<Item = (Self, Option<String>), Error = RedisError>>
[src]

Assigns a name to the current connection. Returns ok if successful, None otherwise.

https://redis.io/commands/client-setname

pub fn dbsize(self) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>[src]

Return the number of keys in the currently-selected database.

https://redis.io/commands/dbsize

pub fn decr<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, i64), Error = RedisError>>
[src]

Decrements the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. Returns error if the key contains a value of the wrong type.

https://redis.io/commands/decr

pub fn decrby<V: Into<RedisValue>, K: Into<RedisKey>>(
    self,
    key: K,
    value: V
) -> Box<dyn Future<Item = (Self, i64), Error = RedisError>>
[src]

Decrements the number stored at key by value argument. If the key does not exist, it is set to 0 before performing the operation. Returns error if the key contains a value of the wrong type.

https://redis.io/commands/decrby

pub fn del<K: Into<MultipleKeys>>(
    self,
    keys: K
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Removes the specified keys. A key is ignored if it does not exist. Returns the number of keys removed.

https://redis.io/commands/del

pub fn dump<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, Option<String>), Error = RedisError>>
[src]

Serialize the value stored at key in a Redis-specific format and return it as bulk string. If key does not exist None is returned

https://redis.io/commands/dump

pub fn exists<K: Into<MultipleKeys>>(
    self,
    keys: K
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Returns number of keys that exist from the keys arguments.

https://redis.io/commands/exists

pub fn expire<K: Into<RedisKey>>(
    self,
    key: K,
    seconds: i64
) -> Box<dyn Future<Item = (Self, bool), Error = RedisError>>
[src]

Set a timeout on key. After the timeout has expired, the key will automatically be deleted. Returns true if timeout set, false if key does not exist.

https://redis.io/commands/expire

pub fn expire_at<K: Into<RedisKey>>(
    self,
    key: K,
    timestamp: i64
) -> Box<dyn Future<Item = (Self, bool), Error = RedisError>>
[src]

Set a timeout on key based on a UNIX timestamp. After the timeout has expired, the key will automatically be deleted. Returns true if timeout set, false if key does not exist.

https://redis.io/commands/expireat

pub fn flushall(
    self,
    async: bool
) -> Box<dyn Future<Item = (Self, String), Error = RedisError>>
[src]

Delete the keys in all databases. Returns a string reply.

https://redis.io/commands/flushall

pub fn flushdb(
    self,
    async: bool
) -> Box<dyn Future<Item = (Self, String), Error = RedisError>>
[src]

Delete all the keys in the currently selected database. Returns a string reply.

https://redis.io/commands/flushalldb

pub fn getrange<K: Into<RedisKey>>(
    self,
    key: K,
    start: usize,
    end: usize
) -> Box<dyn Future<Item = (Self, String), Error = RedisError>>
[src]

Returns the substring of the string value stored at key, determined by the offsets start and end (both inclusive). Note: Command formerly called SUBSTR in Redis verison <=2.0.

https://redis.io/commands/getrange

pub fn getset<V: Into<RedisValue>, K: Into<RedisKey>>(
    self,
    key: K,
    value: V
) -> Box<dyn Future<Item = (Self, Option<RedisValue>), Error = RedisError>>
[src]

Atomically sets key to value and returns the old value stored at key. Returns error if key does not hold string value. Returns None if key does not exist.

https://redis.io/commands/getset

pub fn hdel<F: Into<MultipleKeys>, K: Into<RedisKey>>(
    self,
    key: K,
    fields: F
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Removes the specified fields from the hash stored at key. Specified fields that do not exist within this hash are ignored. If key does not exist, it is treated as an empty hash and this command returns 0.

https://redis.io/commands/hdel

pub fn hexists<F: Into<RedisKey>, K: Into<RedisKey>>(
    self,
    key: K,
    field: F
) -> Box<dyn Future<Item = (Self, bool), Error = RedisError>>
[src]

Returns true if field exists on key.

https://redis.io/commands/hexists

pub fn hget<F: Into<RedisKey>, K: Into<RedisKey>>(
    self,
    key: K,
    field: F
) -> Box<dyn Future<Item = (Self, Option<RedisValue>), Error = RedisError>>
[src]

Returns the value associated with field in the hash stored at key.

https://redis.io/commands/hget

pub fn hgetall<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, HashMap<String, RedisValue>), Error = RedisError>>
[src]

Returns all fields and values of the hash stored at key. In the returned value, every field name is followed by its value Returns an empty hashmap if hash is empty.

https://redis.io/commands/hgetall

pub fn hincrby<F: Into<RedisKey>, K: Into<RedisKey>>(
    self,
    key: K,
    field: F,
    incr: i64
) -> Box<dyn Future<Item = (Self, i64), Error = RedisError>>
[src]

Increments the number stored at field in the hash stored at key by incr. If key does not exist, a new key holding a hash is created. If field does not exist the value is set to 0 before the operation is performed.

https://redis.io/commands/hincrby

pub fn hincrbyfloat<K: Into<RedisKey>, F: Into<RedisKey>>(
    self,
    key: K,
    field: F,
    incr: f64
) -> Box<dyn Future<Item = (Self, f64), Error = RedisError>>
[src]

Increment the specified field of a hash stored at key, and representing a floating point number, by the specified increment. If the field does not exist, it is set to 0 before performing the operation. Returns an error if field value contains wrong type or content/increment are not parsable.

https://redis.io/commands/hincrbyfloat

pub fn hkeys<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, Vec<String>), Error = RedisError>>
[src]

Returns all field names in the hash stored at key. Returns an empty vec if the list is empty. Null fields are converted to "nil".

https://redis.io/commands/hkeys

pub fn hlen<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Returns the number of fields contained in the hash stored at key.

https://redis.io/commands/hlen

pub fn hmget<F: Into<MultipleKeys>, K: Into<RedisKey>>(
    self,
    key: K,
    fields: F
) -> Box<dyn Future<Item = (Self, Vec<RedisValue>), Error = RedisError>>
[src]

Returns the values associated with the specified fields in the hash stored at key. Values in a returned list may be null.

https://redis.io/commands/hmget

pub fn hmset<V: Into<RedisValue>, F: Into<RedisKey> + Hash + Eq, K: Into<RedisKey>>(
    self,
    key: K,
    values: HashMap<F, V>
) -> Box<dyn Future<Item = (Self, String), Error = RedisError>>
[src]

Sets the specified fields to their respective values in the hash stored at key. This command overwrites any specified fields already existing in the hash. If key does not exist, a new key holding a hash is created.

https://redis.io/commands/hmset

pub fn hset<K: Into<RedisKey>, F: Into<RedisKey>, V: Into<RedisValue>>(
    self,
    key: K,
    field: F,
    value: V
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Sets field in the hash stored at key to value. If key does not exist, a new key holding a hash is created. If field already exists in the hash, it is overwritten. Note: Return value of 1 means new field was created and set. Return of 0 means field already exists and was overwritten.

https://redis.io/commands/hset

pub fn hsetnx<K: Into<RedisKey>, F: Into<RedisKey>, V: Into<RedisValue>>(
    self,
    key: K,
    field: F,
    value: V
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Sets field in the hash stored at key to value, only if field does not yet exist. If key does not exist, a new key holding a hash is created. Note: Return value of 1 means new field was created and set. Return of 0 means no operation performed.

https://redis.io/commands/hsetnx

pub fn hstrlen<K: Into<RedisKey>, F: Into<RedisKey>>(
    self,
    key: K,
    field: F
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Returns the string length of the value associated with field in the hash stored at key. If the key or the field do not exist, 0 is returned.

https://redis.io/commands/hstrlen

pub fn hvals<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, Vec<RedisValue>), Error = RedisError>>
[src]

Returns all values in the hash stored at key. Returns an empty vector if the list is empty.

https://redis.io/commands/hvals

pub fn incr<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, i64), Error = RedisError>>
[src]

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

pub fn incrby<K: Into<RedisKey>>(
    self,
    key: K,
    incr: i64
) -> Box<dyn Future<Item = (Self, i64), Error = RedisError>>
[src]

Increments the number stored at key by incr. 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

pub fn incrbyfloat<K: Into<RedisKey>>(
    self,
    key: K,
    incr: f64
) -> Box<dyn Future<Item = (Self, f64), Error = RedisError>>
[src]

Increment the string representing a floating point number stored at key by the argument value. If the key does not exist, it is set to 0 before performing the operation. Returns error if key value is wrong type or if the current value or increment value are not parseable as float value.

https://redis.io/commands/incrbyfloat

pub fn llen<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Returns the length of the list stored at key. If key does not exist, it is interpreted as an empty list and 0 is returned. An error is returned when the value stored at key is not a list.

https://redis.io/commands/llen

pub fn lpush<K: Into<RedisKey>, V: Into<RedisValue>>(
    self,
    key: K,
    value: V
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Insert all the specified values at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations. When key holds a value that is not a list, an error is returned.

https://redis.io/commands/lpush

pub fn lpop<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, Option<RedisValue>), Error = RedisError>>
[src]

Removes and returns the first element of the list stored at key.

https://redis.io/commands/lpop

pub fn sadd<K: Into<RedisKey>, V: Into<RedisValue>>(
    self,
    key: K,
    value: V
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Add the specified members to the set stored at key. Specified members that are already a member of this set are ignored. If key does not exist, a new set is created before adding the specified members. An error is returned when the value stored at key is not a set.

https://redis.io/commands/sadd

pub fn srem<K: Into<RedisKey>, V: Into<RedisValue>>(
    self,
    key: K,
    value: V
) -> Box<dyn Future<Item = (Self, usize), Error = RedisError>>
[src]

Remove the specified members from the set stored at key. Specified members that are not a member of this set are ignored. If key does not exist, it is treated as an empty set and this command returns 0. An error is returned when the value stored at key is not a set.

https://redis.io/commands/srem

pub fn smembers<K: Into<RedisKey>>(
    self,
    key: K
) -> Box<dyn Future<Item = (Self, Vec<RedisValue>), Error = RedisError>>
[src]

Returns all the members of the set value stored at key. This has the same effect as running SINTER with one argument key.

https://redis.io/commands/smembers

Trait Implementations

impl Clone for RedisClient[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for RedisClient[src]

Auto Trait Implementations

impl !Send for RedisClient

impl !Sync for RedisClient

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Erased for T

impl<T> Erased for T