Struct simple_redis::client::Client [] [src]

pub struct Client { /* fields omitted */ }

The redis client which enables to invoke redis operations.

Methods

impl Client
[src]

Defines the redis commands exposed by the redis client.

See redis AUTH command.

Examples

          match client.auth("my_password") {
              Err(error) => println!("Auth error: {}", error),
              _ => println!("Authenticated")
          }

See redis ECHO command.

See redis PUBLISH command.

Examples

          match client.publish("important_notifications", "message text") {
              Err(error) => println!("Publish error: {}", error),
              _ => println!("Message published")
          }

See redis GET command.

Examples

          match client.get("my_key") {
              Ok(value) => println!("Read value from Redis: {}", value),
              Err(error) => println!("Unable to get value from Redis: {}", error)
          }

See redis SET command.

Examples

          match client.set("my_key", "my_value") {
              Err(error) => println!("Unable to set value in Redis: {}", error),
              _ => println!("Value set in Redis")
          }

See redis SETEX command.

Examples

          match client.setex("my_key", "my_value", 10) {
              Err(error) => println!("Unable to set value in Redis: {}", error),
              _ => println!("Value set in Redis and will expire in 10 seconds")
          }

See redis SETNX command.

See redis GETSET command.

See redis DEL command.

See redis EXISTS command.

See redis EXPIRE command.

See redis PERSIST command.

See redis RENAME command.

See redis RENAMENX command.

See redis APPEND command.

See redis INCR command.

See redis INCRBY command.

See redis INCRBYFLOAT command.

See redis STRLEN command.

impl Client
[src]

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.

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.

Examples

          match client.run_command::<String>("ECHO", vec!["testing"]) {
              Ok(value) => assert_eq!(value, "testing"),
              _ => panic!("test error"),
          }

invokes the run_command but returns empty result

invokes the run_command but returns string result

invokes the run_command but returns bool result

Subscribes to the provided channel.
Actual subscription only occurs at the first call to get_message.

Examples

          client.subscribe("important_notifications");

Subscribes to the provided channel pattern.
Actual subscription only occurs at the first call to get_message.

Examples

          client.psubscribe("important_notifications*");

Unsubscribes from the provided channel.

Unsubscribes from the provided channel pattern.

Fetches the next message from any of the subscribed channels.

Examples

          client.subscribe("important_notifications");

          match client.get_message() {
              Ok(message) => {
                  let payload : String = message.get_payload().unwrap();
                  println!("Got message: {}", payload);
              },
              Err(error) => println!("Error while fetching message, should retry again.")
          }