Available on crate feature cluster only.
Expand description

Redis cluster support.

This module extends the library to be able to use cluster. ClusterClient implements traits of ConnectionLike and Commands.

Note that the cluster support currently does not 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::open(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::open(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 is a connection of Redis cluster.

Represents a Redis Cluster command pipeline.

Functions

Shortcut for creating a new cluster pipeline.