Expand description

This is a rust implementation for Redis cluster library.

This library extends redis-rs library to be able to use cluster. Client impletemts traits of ConnectionLike and Commands. So you can use redis-rs’s access methods. If you want more information, read document of redis-rs.

Note that this library is currently not have features of Pubsub.

Example

use redis_cluster_async_tls::{Client, redis::{Commands, cmd}};

#[tokio::main]
async fn main() -> redis::RedisResult<()> {
    let nodes = vec!["redis://127.0.0.1:7000/", "redis://127.0.0.1:7001/", "redis://127.0.0.1:7002/"];

    let client = Client::open(nodes)?;
    let mut connection = client.get_connection().await?;
    cmd("SET").arg("test").arg("test_data").query_async(&mut connection).await?;
    let res: String = cmd("GET").arg("test").query_async(&mut connection).await?;
    assert_eq!(res, "test_data");
    Ok(())
}

Pipelining

use redis_cluster_async_tls::{Client, redis::pipe};

#[tokio::main]
async fn main() -> redis::RedisResult<()> {
    let nodes = vec!["redis://127.0.0.1:7000/", "redis://127.0.0.1:7001/", "redis://127.0.0.1:7002/"];

    let client = Client::open(nodes)?;
    let mut connection = client.get_connection().await?;
    let key = "test2";

    let mut pipe = pipe();
    pipe.rpush(key, "123").ignore()
        .ltrim(key, -10, -1).ignore()
        .expire(key, 60).ignore();
    pipe.query_async(&mut connection)
        .await?;
    Ok(())
}

Re-exports

pub use redis;

Structs

This is a Redis cluster client.
This is a connection of Redis cluster.

Traits