r2d2_redis_cluster2

Crates.ior2d2_redis_cluster2
lib.rsr2d2_redis_cluster2
version0.23.3
sourcesrc
created_at2024-01-28 01:12:18.819589
updated_at2024-01-28 01:12:18.819589
descriptionRedis cluster support for the r2d2 connection pool.
homepagehttps://github.com/chunhui2001/r2d2_redis_cluster2
repositoryhttps://github.com/chunhui2001/r2d2_redis_cluster2
max_upload_size
id1117213
size7,151
Keesh (chunhui2001)

documentation

README

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);
}
Commit count: 0

cargo fmt