#redis-cluster #connection-pool

r2d2_redis_cluster

Redis cluster support for the r2d2 connection pool

7 releases

Uses old Rust 2015

0.1.6 Jan 4, 2021
0.1.5 Jul 23, 2019
0.1.4 Jun 16, 2019
0.1.3 May 4, 2019
0.1.0 May 7, 2018

#17 in #redis-cluster

Download history 19/week @ 2024-07-22 52/week @ 2024-07-29 31/week @ 2024-08-05 43/week @ 2024-08-12 23/week @ 2024-08-19 21/week @ 2024-08-26 21/week @ 2024-09-02 28/week @ 2024-09-09 11/week @ 2024-09-16 128/week @ 2024-09-23 14/week @ 2024-09-30 31/week @ 2024-10-07 124/week @ 2024-10-14 82/week @ 2024-10-21 16/week @ 2024-10-28 30/week @ 2024-11-04

252 downloads per month

MIT license

8KB
84 lines

MIT licensed

Redis cluster support for the r2d2 connection pool.

Documentation is available at here.

Example

extern crate r2d2_redis_cluster;

use std::thread;

use r2d2_redis_cluster::{r2d2::Pool, Commands, RedisClusterConnectionManager};

fn main() {
    let redis_uri = vec!["redis://127.0.0.1:6379", "redis://127.0.0.1:6378", "redis://127.0.0.1:6377"];
    let manager = RedisClusterConnectionManager::new(redis_uri).unwrap();
    let pool = Pool::builder()
        .build(manager)
        .unwrap();

    let mut handles = Vec::new();

    for _ in 0..10 {
        let pool = pool.clone();
        handles.push(thread::spawn(move || {
            let connection = pool.get().unwrap();
            let n: u64 = connection.incr("test", 1).unwrap();
        }));
    }

    for h in handles {
        h.join().unwrap();
    }

    let mut connection = pool.get().unwrap();
    let res: u64 = connection.get("test").unwrap();

    assert_eq!(res, 10);
}

Dependencies

~7–13MB
~165K SLoC