| Crates.io | bb8-valkey |
| lib.rs | bb8-valkey |
| version | 0.0.0-alpha2 |
| created_at | 2024-12-04 05:56:36.53743+00 |
| updated_at | 2024-12-04 05:58:07.402524+00 |
| description | A connection pool for Valkey |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1471280 |
| size | 3,398 |
A connection pool for tokio-valkey.
It is still a work-in-progress.
use bb8::Pool;
use bb8_valkey::ValkeyConnectionManager;
use futures_util::future::join_all;
use std::net::{Ipv6Addr, SocketAddr};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = SocketAddr::from((Ipv6Addr::LOCALHOST, 6379));
let manager = ValkeyConnectionManager::new(addr).await?;
let pool = Pool::builder().build(manager).await?;
let mut handles = Vec::with_capacity(10);
for _i in 0..10 {
let pool = pool.clone();
handles.push(tokio::spawn(async move {
let mut conn = pool.get().await.unwrap();
// this is not implemented yet
let reply: String = cmd("PING").query_async(&mut *conn).await.unwrap();
assert_eq!("PONG", reply);
}));
}
join_all(handles).await;
Ok(())
}