redis_pool-0.1.0 has been yanked.
License
This project is licensed under either Apache License, Version 2.0, zlib License, or MIT License, at your option.
Help
If you need help with this library or have suggestions please go to our Discord Group
Install
RedisPool uses tokio runtime.
[dependencies]
redis_pool = "0.1.0"
Cargo Feature Flags
axum: Enables axum FromRequestParts to retrieve from State.
json: Enabled serde's json for Redis.
cluster: Enabled Redis Cluster Client and connections.
Example
use redis_pool::{RedisConnectionManager};
use axum::{
Router,
routing::get,
};
use std::time::Duration;
#[tokio::main]
async fn main() {
let redis_url = "redis://default:YourSecretPassWord@127.0.0.1:6379/0";
let client = redis::Client::open(redis_url).expect("Error while testing the connection");
let manager = RedisConnectionManager::new(client, 5);
let app = Router::with_state(manager)
.route("/drop", get(drop_table));
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
tracing::debug!("listening on {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
}
async fn test_pool(manager: RedisConnectionManager) -> String {
let mut connection = manager.aquire().await.unwrap();
redis::pipe()
.set(0, "Hello")
.ignore()
.query_async(&mut connection)
.await.unwrap();
redis::cmd("GET").arg(0).query_async(&mut connection).await.unwrap()
}