Struct simple_redis::client::Client [−][src]
pub struct Client { /* fields omitted */ }Expand description
The redis client which enables to invoke redis operations.
Implementations
Returns true if the currently stored connection is valid, otherwise false.
There is no need to call this function as any redis operation invocation will
ensure a valid connection is created.
pub fn run_command<T: FromRedisValue>(
self: &mut Client,
command: &str,
args: Vec<&str>
) -> RedisResult<T>
pub fn run_command<T: FromRedisValue>(
self: &mut Client,
command: &str,
args: Vec<&str>
) -> RedisResult<T>Invokes the requested command with the provided arguments (all provided via args) and returns the operation
response.
This function ensures that we have a valid connection and it is used internally by all other exposed
commands.
This function is also public to enable invoking operations that are not directly exposed by the client.
Arguments
command- The Redis command, for example:GETargs- Vector of arguments for the given command
Example
match client.run_command::<String>("ECHO", vec!["testing"]) { Ok(value) => assert_eq!(value, "testing"), _ => panic!("test error"), }
pub fn run_command_from_string_response<T: FromStr>(
self: &mut Client,
command: &str,
args: Vec<&str>
) -> RedisResult<T>
pub fn run_command_from_string_response<T: FromStr>(
self: &mut Client,
command: &str,
args: Vec<&str>
) -> RedisResult<T>invokes the run_command and returns typed result
pub fn run_command_empty_response(
self: &mut Client,
command: &str,
args: Vec<&str>
) -> RedisEmptyResult
pub fn run_command_empty_response(
self: &mut Client,
command: &str,
args: Vec<&str>
) -> RedisEmptyResultinvokes the run_command but returns empty result
pub fn run_command_string_response(
self: &mut Client,
command: &str,
args: Vec<&str>
) -> RedisStringResult
pub fn run_command_string_response(
self: &mut Client,
command: &str,
args: Vec<&str>
) -> RedisStringResultinvokes the run_command but returns string result
pub fn run_command_bool_response(
self: &mut Client,
command: &str,
args: Vec<&str>
) -> RedisBoolResult
pub fn run_command_bool_response(
self: &mut Client,
command: &str,
args: Vec<&str>
) -> RedisBoolResultinvokes the run_command but returns bool result
Returns true if subscribed to the provided channel.
Returns true if subscribed to the provided channel pattern.
Unsubscribes from the provided channel.
Unsubscribes from the provided channel pattern.
Unsubscribes from all channels.
pub fn fetch_messages(
self: &mut Client,
on_message: &mut dyn FnMut(Message) -> bool,
poll_interrupts: &mut dyn FnMut() -> Interrupts
) -> RedisEmptyResult
pub fn fetch_messages(
self: &mut Client,
on_message: &mut dyn FnMut(Message) -> bool,
poll_interrupts: &mut dyn FnMut() -> Interrupts
) -> RedisEmptyResultFetches the messages from any of the subscribed channels and invokes the provided
on_message handler.
This function will return an error in case no subscriptions are defined.
This function will block and continue to listen to all messages, until either the
on_message returns true.
Arguments
on_message- Invoked on each read message. If returns true, the fetching will stop.poll_interrupts- Returns the interrupts struct, enabling to modify the fetching.
Example
client.subscribe("important_notifications"); // fetch messages from all subscriptions client.fetch_messages( &mut |message: simple_redis::Message| -> bool { let payload : String = message.get_payload().unwrap(); println!("Got message: {}", payload); // continue fetching false }, &mut || -> Interrupts { Interrupts::new() }, ).unwrap();
Defines the redis commands exposed by the redis client.
See redis ECHO command.
See redis SETNX command.
See redis GETSET command.
See redis GETSET command.
See redis DEL command.
See redis EXISTS command.
See redis EXPIRE command.
See redis PEXPIRE command.
See redis PERSIST command.
See redis RENAME command.
See redis RENAMENX command.
See redis INCRBY command.
See redis INCRBYFLOAT command.
See redis HGET command.
See redis HGET command.
See redis HSET command.
See redis HSETNX command.
See redis HDEL command.
See redis HEXISTS command.
See redis LSET command.
See redis HGET command.
See redis HGET command.
See redis LPUSH command.
See redis LPUSHX command.
See redis LRANGE command.
See redis LREM command.
See redis LTRIM command.
See redis RPUSH command.
See redis RPUSHX command.
See redis SADD command.
See redis SDIFF command.
See redis SISMEMBER command.
See redis SMEMBERS command.
See redis SMOVE command.
See redis SREM command.
See redis ZADD command.
Auto Trait Implementations
impl !RefUnwindSafe for Clientimpl !UnwindSafe for Client