Struct fred::RedisClient
[−]
[src]
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<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<Future<Item = (), Error = RedisError>>
[src]
&self,
handle: &Handle,
policy: ReconnectPolicy
) -> Box<Future<Item = (), Error = RedisError>>
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<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<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<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<Stream<Item = (String, RedisValue), Error = RedisError>>
[src]
&self
) -> Box<Stream<Item = (String, RedisValue), Error = RedisError>>
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<Future<Item = Vec<(RedisClient, RedisConfig)>, Error = RedisError>>
[src]
&self,
handle: &Handle
) -> Box<Future<Item = Vec<(RedisClient, RedisConfig)>, Error = RedisError>>
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<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<Future<Item = (Self, String), Error = RedisError>>
[src]
self,
section: Option<InfoKind>
) -> Box<Future<Item = (Self, String), Error = RedisError>>
Read info about the Redis server.
https://redis.io/commands/info
pub fn ping(self) -> Box<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<Future<Item = (Self, usize), Error = RedisError>>
[src]
self,
channel: T
) -> Box<Future<Item = (Self, usize), Error = RedisError>>
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<Future<Item = (Self, usize), Error = RedisError>>
[src]
self,
channel: T
) -> Box<Future<Item = (Self, usize), Error = RedisError>>
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<Future<Item = (Self, i64), Error = RedisError>>
[src]
self,
channel: T,
message: V
) -> Box<Future<Item = (Self, i64), Error = RedisError>>
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<Future<Item = (Self, Option<RedisValue>), Error = RedisError>>
[src]
self,
key: K
) -> Box<Future<Item = (Self, Option<RedisValue>), Error = RedisError>>
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<Future<Item = (Self, bool), Error = RedisError>>
[src]
self,
key: K,
value: V,
expire: Option<Expiration>,
options: Option<SetOptions>
) -> Box<Future<Item = (Self, bool), Error = RedisError>>
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<Future<Item = (Self, String), Error = RedisError>>
[src]
self,
value: V
) -> Box<Future<Item = (Self, String), Error = RedisError>>
Request for authentication in a password-protected Redis server. Returns ok if successful.
https://redis.io/commands/auth
pub fn bgrewriteaof(
self
) -> Box<Future<Item = (Self, String), Error = RedisError>>
[src]
self
) -> Box<Future<Item = (Self, String), Error = RedisError>>
Instruct Redis to start an Append Only File rewrite process. Returns ok.
https://redis.io/commands/bgrewriteaof
pub fn bgsave(self) -> Box<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<Future<Item = (Self, String), Error = RedisError>>
[src]
self
) -> Box<Future<Item = (Self, String), Error = RedisError>>
Returns information and statistics about the client connections.
https://redis.io/commands/client-list
pub fn client_getname(
self
) -> Box<Future<Item = (Self, Option<String>), Error = RedisError>>
[src]
self
) -> Box<Future<Item = (Self, Option<String>), Error = RedisError>>
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<Future<Item = (Self, Option<String>), Error = RedisError>>
[src]
self,
name: V
) -> Box<Future<Item = (Self, Option<String>), Error = RedisError>>
Assigns a name to the current connection. Returns ok if successful, None otherwise.
https://redis.io/commands/client-setname
pub fn dbsize(self) -> Box<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<Future<Item = (Self, i64), Error = RedisError>>
[src]
self,
key: K
) -> Box<Future<Item = (Self, i64), Error = RedisError>>
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<Future<Item = (Self, i64), Error = RedisError>>
[src]
self,
key: K,
value: V
) -> Box<Future<Item = (Self, i64), Error = RedisError>>
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<Future<Item = (Self, usize), Error = RedisError>>
[src]
self,
keys: K
) -> Box<Future<Item = (Self, usize), Error = RedisError>>
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<Future<Item = (Self, Option<String>), Error = RedisError>>
[src]
self,
key: K
) -> Box<Future<Item = (Self, Option<String>), Error = RedisError>>
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<Future<Item = (Self, usize), Error = RedisError>>
[src]
self,
keys: K
) -> Box<Future<Item = (Self, usize), Error = RedisError>>
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<Future<Item = (Self, bool), Error = RedisError>>
[src]
self,
key: K,
seconds: i64
) -> Box<Future<Item = (Self, bool), Error = RedisError>>
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<Future<Item = (Self, bool), Error = RedisError>>
[src]
self,
key: K,
timestamp: i64
) -> Box<Future<Item = (Self, bool), Error = RedisError>>
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<Future<Item = (Self, String), Error = RedisError>>
[src]
self,
async: bool
) -> Box<Future<Item = (Self, String), Error = RedisError>>
Delete the keys in all databases. Returns a string reply.
https://redis.io/commands/flushall
pub fn flushdb(
self,
async: bool
) -> Box<Future<Item = (Self, String), Error = RedisError>>
[src]
self,
async: bool
) -> Box<Future<Item = (Self, String), Error = RedisError>>
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<Future<Item = (Self, String), Error = RedisError>>
[src]
self,
key: K,
start: usize,
end: usize
) -> Box<Future<Item = (Self, String), Error = RedisError>>
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<Future<Item = (Self, Option<RedisValue>), Error = RedisError>>
[src]
self,
key: K,
value: V
) -> Box<Future<Item = (Self, Option<RedisValue>), Error = RedisError>>
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<Future<Item = (Self, usize), Error = RedisError>>
[src]
self,
key: K,
fields: F
) -> Box<Future<Item = (Self, usize), Error = RedisError>>
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<Future<Item = (Self, bool), Error = RedisError>>
[src]
self,
key: K,
field: F
) -> Box<Future<Item = (Self, bool), Error = RedisError>>
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<Future<Item = (Self, Option<RedisValue>), Error = RedisError>>
[src]
self,
key: K,
field: F
) -> Box<Future<Item = (Self, Option<RedisValue>), Error = RedisError>>
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<Future<Item = (Self, HashMap<String, RedisValue>), Error = RedisError>>
[src]
self,
key: K
) -> Box<Future<Item = (Self, HashMap<String, RedisValue>), Error = RedisError>>
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<Future<Item = (Self, i64), Error = RedisError>>
[src]
self,
key: K,
field: F,
incr: i64
) -> Box<Future<Item = (Self, i64), Error = RedisError>>
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<Future<Item = (Self, f64), Error = RedisError>>
[src]
self,
key: K,
field: F,
incr: f64
) -> Box<Future<Item = (Self, f64), Error = RedisError>>
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<Future<Item = (Self, Vec<String>), Error = RedisError>>
[src]
self,
key: K
) -> Box<Future<Item = (Self, Vec<String>), Error = RedisError>>
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<Future<Item = (Self, usize), Error = RedisError>>
[src]
self,
key: K
) -> Box<Future<Item = (Self, usize), Error = RedisError>>
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<Future<Item = (Self, Vec<RedisValue>), Error = RedisError>>
[src]
self,
key: K,
fields: F
) -> Box<Future<Item = (Self, Vec<RedisValue>), Error = RedisError>>
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<Future<Item = (Self, String), Error = RedisError>>
[src]
self,
key: K,
values: HashMap<F, V>
) -> Box<Future<Item = (Self, String), Error = RedisError>>
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<Future<Item = (Self, usize), Error = RedisError>>
[src]
self,
key: K,
field: F,
value: V
) -> Box<Future<Item = (Self, usize), Error = RedisError>>
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<Future<Item = (Self, usize), Error = RedisError>>
[src]
self,
key: K,
field: F,
value: V
) -> Box<Future<Item = (Self, usize), Error = RedisError>>
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<Future<Item = (Self, usize), Error = RedisError>>
[src]
self,
key: K,
field: F
) -> Box<Future<Item = (Self, usize), Error = RedisError>>
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<Future<Item = (Self, Vec<RedisValue>), Error = RedisError>>
[src]
self,
key: K
) -> Box<Future<Item = (Self, Vec<RedisValue>), Error = RedisError>>
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<Future<Item = (Self, i64), Error = RedisError>>
[src]
self,
key: K
) -> Box<Future<Item = (Self, i64), Error = RedisError>>
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<Future<Item = (Self, i64), Error = RedisError>>
[src]
self,
key: K,
incr: i64
) -> Box<Future<Item = (Self, i64), Error = RedisError>>
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<Future<Item = (Self, f64), Error = RedisError>>
[src]
self,
key: K,
incr: f64
) -> Box<Future<Item = (Self, f64), Error = RedisError>>
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
Trait Implementations
impl Clone for RedisClient
[src]
fn clone(&self) -> RedisClient
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more