Crates.io | poolx-redis |
lib.rs | poolx-redis |
version | 0.1.2 |
source | src |
created_at | 2024-03-01 02:28:55.90173 |
updated_at | 2024-03-01 02:28:55.90173 |
description | poolx for redis, with many features like idle connection checking and reaping, healthcheck, and more. |
homepage | |
repository | https://github.com/arthur-zhang/poolx |
max_upload_size | |
id | 1158399 |
size | 6,311 |
Poolx is a generic connection pool implementation for Rust, Its original code is from sqlx, and I have made many changes to make it more generic and remove lots of useless code.
#[tokio::main]
async fn main() {
let url = "redis://:foobared@127.0.0.1:6379";
let option = url.parse::<RedisConnectionOption>().unwrap();
let pool: Pool<RedisConnection> = PoolOptions::new()
.test_before_acquire(true)
.idle_timeout(std::time::Duration::from_secs(3))
.min_connections(3)
.max_connections(100)
.connect_lazy_with(option);
for i in 0..10 {
let mut conn = pool.acquire().await.unwrap();
let reply: String = cmd("PING").query_async(conn.as_mut()).await.unwrap();
println!("reply: {}", reply);
}
}