#redis-cluster

bb8-redis-cluster

Full-featured async (tokio-based) redis cluster connection pool (like r2d2)

2 releases

0.1.1 May 8, 2023
0.1.0 Oct 18, 2022

#17 in #redis-cluster

Download history 283/week @ 2024-06-21 199/week @ 2024-06-28 206/week @ 2024-07-05 142/week @ 2024-07-12 174/week @ 2024-07-19 144/week @ 2024-07-26 148/week @ 2024-08-02 161/week @ 2024-08-09 242/week @ 2024-08-16 262/week @ 2024-08-23 211/week @ 2024-08-30 305/week @ 2024-09-06 148/week @ 2024-09-13 209/week @ 2024-09-20 257/week @ 2024-09-27 287/week @ 2024-10-04

953 downloads per month

BSD-2-Clause

6KB

bb8-redis-cluster

A Async redis cluster connection pool (bb8).

Example

#[tokio::main]
async fn main() {
    let manager = RedisConnectionManager::new(vec!["redis://localhost:1234"]).unwrap();
    let pool = bb8::Pool::builder()
        .max_size(15)
        .build(manager)
        .await
        .unwrap();

    for _ in 0..20 {
        let pool = pool.clone();
        tokio::spawn(async move {
            let mut conn = pool.get().await.unwrap();
            let reply: String = cmd("PING").query_async(&mut *conn).await.unwrap();
            assert_eq!("PONG", reply);
        });
    }
}

lib.rs:

Redis Cluster support for the bb8 connection pool.

Example

use futures_util::future::join_all;
use bb8_redis_cluster::{
    bb8,
    redis_cluster_async::redis::{cmd, AsyncCommands},
    RedisConnectionManager
};

#[tokio::main]
async fn main() {
    let manager = RedisConnectionManager::new(vec!["redis://localhost"]).unwrap();
    let pool = bb8::Pool::builder().build(manager).await.unwrap();

    let mut handles = vec![];

    for _i in 0..10 {
        let pool = pool.clone();

        handles.push(tokio::spawn(async move {
            let mut conn = pool.get().await.unwrap();

            let reply: String = cmd("PING").query_async(&mut *conn).await.unwrap();

            assert_eq!("PONG", reply);
        }));
    }

    join_all(handles).await;
}

Dependencies

~7–17MB
~226K SLoC