Available on crate feature
cluster
only.Expand description
This module extends the library to support Redis Cluster.
Note that this module does not currently provide pubsub functionality.
Example
use redis::Commands;
use redis::cluster::ClusterClient;
let nodes = vec!["redis://127.0.0.1:6379/", "redis://127.0.0.1:6378/", "redis://127.0.0.1:6377/"];
let client = ClusterClient::new(nodes).unwrap();
let mut connection = client.get_connection().unwrap();
let _: () = connection.set("test", "test_data").unwrap();
let rv: String = connection.get("test").unwrap();
assert_eq!(rv, "test_data");
Pipelining
use redis::Commands;
use redis::cluster::{cluster_pipe, ClusterClient};
let nodes = vec!["redis://127.0.0.1:6379/", "redis://127.0.0.1:6378/", "redis://127.0.0.1:6377/"];
let client = ClusterClient::new(nodes).unwrap();
let mut connection = client.get_connection().unwrap();
let key = "test";
let _: () = cluster_pipe()
.rpush(key, "123").ignore()
.ltrim(key, -10, -1).ignore()
.expire(key, 60).ignore()
.query(&mut connection).unwrap();
Structs
- This is a Redis Cluster client.
- Used to configure and build a
ClusterClient
. - This represents a Redis Cluster connection. It stores the underlying connections maintained for each node in the cluster, as well as common parameters for connecting to nodes and executing commands.
- Represents a Redis Cluster command pipeline.
Enums
- TlsMode indicates use or do not use verification of certification. Check ConnectionAddr for more.
Traits
- Implements the process of connecting to a Redis server and obtaining and configuring a connection handle.
Functions
- Shortcut for creating a new cluster pipeline.