👎Deprecated since 0.1.1: The functionality of
redis_cluster_async has been merged into the
redis crate rendering this crate obsolete. Please use deadpool-redis instead.Expand description
§Deadpool for Redis Cluster

§⚠️ DEPRECATED! ⚠️
The functionality of redis_cluster_async has been merged into the
redis crate rendering this crate obsolete.
Please use deadpool-redis instead.
§⚠️ DEPRECATED! ⚠️
Deadpool is a dead simple async pool for connections and objects of any type.
This crate implements a deadpool
manager for redis-cluster.
§Features
| Feature | Description | Extra dependencies | Default |
|---|---|---|---|
rt_tokio_1 | Enable support for tokio crate | deadpool/rt_tokio_1, redis/tokio-comp | yes |
rt_async-std_1 | Enable support for async-std crate | deadpool/rt_async-std_1, redis/async-std-comp | no |
serde | Enable support for serde crate | deadpool/serde, serde/derive | no |
§Example
use std::env;
use deadpool_redis_cluster::{redis::{cmd, FromRedisValue}, Config, Runtime};
#[tokio::main]
async fn main() {
let redis_urls = env::var("REDIS_CLUSTER__URLS")
.unwrap()
.split(',')
.map(String::from)
.collect::<Vec<_>>();
let mut cfg = Config::from_urls(redis_urls);
let pool = cfg.create_pool(Some(Runtime::Tokio1)).unwrap();
{
let mut conn = pool.get().await.unwrap();
cmd("SET")
.arg(&["deadpool/test_key", "42"])
.query_async::<_, ()>(&mut conn)
.await.unwrap();
}
{
let mut conn = pool.get().await.unwrap();
let value: String = cmd("GET")
.arg(&["deadpool/test_key"])
.query_async(&mut conn)
.await.unwrap();
assert_eq!(value, "42".to_string());
}
}§Example with config and dotenv crate
use deadpool_redis_cluster::{redis::{cmd, FromRedisValue}, Runtime};
use dotenv::dotenv;
#[derive(Debug, serde::Deserialize)]
struct Config {
#[serde(default)]
redis_cluster: deadpool_redis_cluster::Config
}
impl Config {
pub fn from_env() -> Result<Self, config::ConfigError> {
config::Config::builder()
.add_source(
config::Environment::default()
.separator("__")
.try_parsing(true)
.list_separator(","),
)
.build()?
.try_deserialize()
}
}
#[tokio::main]
async fn main() {
dotenv().ok();
let cfg = Config::from_env().unwrap();
let pool = cfg.redis_cluster.create_pool(Some(Runtime::Tokio1)).unwrap();
{
let mut conn = pool.get().await.unwrap();
cmd("SET")
.arg(&["deadpool/test_key", "42"])
.query_async::<_, ()>(&mut conn)
.await.unwrap();
}
{
let mut conn = pool.get().await.unwrap();
let value: String = cmd("GET")
.arg(&["deadpool/test_key"])
.query_async(&mut conn)
.await.unwrap();
assert_eq!(value, "42".to_string());
}
}§FAQ
-
How can I enable features of the
rediscrate?Make sure that you depend on the same version of
redisasdeadpool-redis-clusterdoes and enable the needed features in your ownCrate.tomlfile:[dependencies] deadpool-redis-cluster = { version = "0.9", features = ["serde"] } redis = { version = "0.21", default-features = false, features = ["tls"] }
§License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Re-exports§
pub use redis;
Structs§
- Client
- This is a Redis cluster client.
- Config
Deprecated - Configuration object.
- Connection
Deprecated - Wrapper around
redis_cluster_async::Connection. - Manager
Deprecated Managerfor creating and recyclingredis_cluster_asyncconnections.- Metrics
- Statistics regarding an object returned by the pool
- Pool
Config Poolconfiguration.- Redis
Connection - This is a connection of Redis cluster.
- Status
- The current pool status.
- Timeouts
- Timeouts when getting
Objects from aPool.
Enums§
- Config
Error Deprecated - This error is returned if the configuration contains an error
- Runtime
- Enumeration for picking a runtime implementation.
Type Aliases§
- Build
Error Deprecated - Type alias for using
deadpool::managed::BuildErrorwith [redis_cluster]. - Create
Pool Error Deprecated - Type alias for using
deadpool::managed::CreatePoolErrorwith [redis_cluster]. - Hook
Deprecated - Type alias for using
deadpool::managed::Hookwith [redis_cluster]. - Hook
Error Deprecated - Type alias for using
deadpool::managed::HookErrorwith [redis_cluster]. - Object
Deprecated - Type alias for using
deadpool::managed::Objectwith [redis_cluster]. - Pool
Deprecated - Type alias for using
deadpool::managed::Poolwith [redis_cluster]. - Pool
Builder Deprecated - Type alias for using
deadpool::managed::PoolBuilderwith [redis_cluster]. - Pool
Error Deprecated - Type alias for using
deadpool::managed::PoolErrorwith [redis_cluster].