11 releases

Uses old Rust 2015

0.1.10 Jan 4, 2021
0.1.9 Aug 12, 2019
0.1.8 Jul 23, 2019
0.1.7 Jun 16, 2019
0.1.1 May 7, 2018

#17 in #redis-cluster

Download history 95/week @ 2024-01-04 174/week @ 2024-01-11 186/week @ 2024-01-18 102/week @ 2024-01-25 53/week @ 2024-02-01 49/week @ 2024-02-08 186/week @ 2024-02-15 220/week @ 2024-02-22 152/week @ 2024-02-29 140/week @ 2024-03-07 170/week @ 2024-03-14 103/week @ 2024-03-21 107/week @ 2024-03-28 91/week @ 2024-04-04 22/week @ 2024-04-11 39/week @ 2024-04-18

268 downloads per month
Used in r2d2_redis_cluster

MIT license

31KB
629 lines

MIT licensed

This is a Rust implementation for Redis cluster library.

Documentation is available at here.

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

extern crate redis_cluster_rs;

use redis_cluster_rs::{Client, Commands};

fn main() {
    let nodes = vec!["redis://127.0.0.1:6379/", "redis://127.0.0.1:6378/", "redis://127.0.0.1:6377/"];
    let client = Client::open(nodes).unwrap();
    let mut connection = client.get_connection().unwrap();

    let _: () = connection.set("test", "test_data").unwrap();
    let res: String = connection.get("test").unwrap();

    assert_eq!(res, "test_data");
}

Pipelining

extern crate redis_cluster_rs;

use redis_cluster_rs::{Client, 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 client = Client::open(nodes).unwrap();
    let mut connection = client.get_connection().unwrap();

    let key = "test";

    let _: () = pipe()
        .rpush(key, "123").ignore()
        .ltrim(key, -10, -1).ignore()
        .expire(key, 60).ignore()
        .query(&mut connection).unwrap();
}

Dependencies

~7MB
~156K SLoC