Crate bb8_redis_cluster
source ·Expand description
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;
}
Re-exports
pub use bb8;
pub use redis_cluster_async;
Structs
- A
bb8::ManageConnection
forredis_cluster_async::Client::get_connection
.