#redis #cluster #async

redis_cluster_async

Async redis cluster driver for Rust

13 releases (7 breaking)

0.8.1 Aug 10, 2023
0.8.0 Apr 5, 2023
0.7.2 Feb 7, 2023
0.7.0 Jul 16, 2021
0.1.1 Nov 15, 2019

#82 in Database interfaces

Download history 1085/week @ 2023-08-10 1065/week @ 2023-08-17 1210/week @ 2023-08-24 751/week @ 2023-08-31 1032/week @ 2023-09-07 1223/week @ 2023-09-14 960/week @ 2023-09-21 898/week @ 2023-09-28 1041/week @ 2023-10-05 879/week @ 2023-10-12 785/week @ 2023-10-19 939/week @ 2023-10-26 830/week @ 2023-11-02 760/week @ 2023-11-09 573/week @ 2023-11-16 619/week @ 2023-11-23

2,919 downloads per month
Used in 7 crates (6 directly)

MIT license

51KB
1K SLoC

MIT licensed

⚠️ DEPRECATED! ⚠️

The functionality of this crate has been merged into the main redis-rs project.

⚠️ DEPRECATED! ⚠️

A Rust crate implementing a Redis cluster client.

Documentation is available at here.

This library builds upon the redis-rs crate to enable working with a Redis cluster (instead of single Redis nodes).

Example

extern crate futures;
extern crate tokio;
use futures::prelude::*;
use redis_cluster_async::{Client, redis::cmd};

fn main() {
    let nodes = vec!["redis://127.0.0.1:6379/", "redis://127.0.0.1:6378/", "redis://127.0.0.1:6377/"];

    let mut runtime = tokio::runtime::Runtime::new().unwrap();

    let client = Client::open(nodes).unwrap();
    let (_, res): (_, String) = runtime.block_on(client.get_connection()
        .and_then(|connection| {
            cmd("SET").arg("test").arg("test_data").clone()
                .query_async(connection)
                .and_then(|(connection, ())|
                    cmd("GET").arg("test")
                        .query_async(connection)
                )
        })
        )
        .unwrap();

    assert_eq!(res, "test_data");
}

Pipelining

extern crate futures;
extern crate tokio;

use futures::prelude::*;
use redis_cluster_async::{Client, redis::{PipelineCommands, pipe}};

fn main() {
    let nodes = vec!["redis://127.0.0.1:6379/", "redis://127.0.0.1:6378/", "redis://127.0.0.1:6377/"];

    let mut runtime = tokio::runtime::Runtime::new().unwrap();

    let client = Client::open(nodes).unwrap();
    let _: (_, ()) = runtime.block_on(
        client.get_connection().and_then(|connection| {
            let key = "test";

            pipe()
                .rpush(key, "123").ignore()
                .ltrim(key, -10, -1).ignore()
                .expire(key, 60).ignore()
                .query_async(connection)
        }))
        .unwrap();

}

Acknowledgements

This project is built upon the synchronous redis cluster implementation in https://github.com/atuk721/redis-cluster-rs .

Dependencies

~6–17MB
~254K SLoC