Struct fred::RedisClient [] [src]

pub struct RedisClient { /* fields omitted */ }

A Redis client.

Methods

impl RedisClient
[src]

[src]

Create a new RedisClient instance.

[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.

[src]

Read the state of the underlying connection.

[src]

Read latency metrics across all commands.

[src]

Read and consume latency metrics, resetting their values afterwards.

[src]

Read payload size metrics across all commands.

[src]

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

[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.

[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.

[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.

[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.

[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.

[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.

[src]

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

[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.

[src]

Select the database this client should use.

https://redis.io/commands/select

[src]

Read info about the Redis server.

https://redis.io/commands/info

[src]

Ping the Redis server.

https://redis.io/commands/ping

[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

[src]

Unsubscribe from a channel on the PubSub interface.

https://redis.io/commands/unsubscribe

[src]

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

https://redis.io/commands/publish

[src]

Read a value from Redis at key.

https://redis.io/commands/get

[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

[src]

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

https://redis.io/commands/auth

[src]

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

https://redis.io/commands/bgrewriteaof

[src]

Save the DB in background. Returns ok.

https://redis.io/commands/bgsave

[src]

Returns information and statistics about the client connections.

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

[src]

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

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

[src]

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

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

[src]

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

https://redis.io/commands/dbsize

[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

[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

[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

[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

[src]

Returns number of keys that exist from the keys arguments.

https://redis.io/commands/exists

[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

[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

[src]

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

https://redis.io/commands/flushall

[src]

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

https://redis.io/commands/flushalldb

[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

[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

[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

[src]

Returns true if field exists on key.

https://redis.io/commands/hexists

[src]

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

https://redis.io/commands/hget

[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

[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

[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

[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

[src]

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

https://redis.io/commands/hlen

[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

[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

[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

[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

[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

[src]

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

https://redis.io/commands/hvals

[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

[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

[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

Trait Implementations

impl Clone for RedisClient
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for RedisClient
[src]

[src]

Formats the value using the given formatter.