Deadpool for Redis Latest Version

Deadpool is a dead simple async pool for connections and objects of any type.

This crate implements a deadpool manager for redis.

Features

| Feature | Description | Extra dependencies | Default | | ------- | ----------- | ------------------ | ------- | | config | Enable support for config crate | config, serde/derive | yes | | 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 |

Example

```rust,ignore use deadpool_redis::redis::{cmd, Config, FromRedisValue};

[tokio::main]

async fn main() { let mut cfg = Config::default(); cfg.url = Some("redis://127.0.0.1/".tostring()); let pool = cfg.createpool().unwrap(); { let mut conn = pool.get().await.unwrap(); cmd("SET") .arg(&["deadpool/testkey", "42"]) .queryasync::<_, ()>(&mut conn) .await.unwrap(); } { let mut conn = pool.get().await.unwrap(); let value: String = cmd("GET") .arg(&["deadpool/testkey"]) .queryasync(&mut conn) .await.unwrap(); asserteq!(value, "42".tostring()); } } ```

Example with config and dotenv crate

```rust use deadpool_redis::redis::{cmd, FromRedisValue}; use dotenv::dotenv; use serde::Deserialize;

[derive(Debug, Deserialize)]

struct Config { #[serde(default)] redis: deadpool_redis::Config }

impl Config { pub fn fromenv() -> Result { let mut cfg = ::configcrate::Config::new(); cfg.merge(::configcrate::Environment::new().separator(""))?; cfg.tryinto() } }

[tokio::main]

async fn main() { dotenv().ok(); let cfg = Config::fromenv().unwrap(); let pool = cfg.redis.createpool().unwrap(); { let mut conn = pool.get().await.unwrap(); cmd("SET") .arg(&["deadpool/testkey", "42"]) .queryasync::<_, ()>(&mut conn) .await.unwrap(); } { let mut conn = pool.get().await.unwrap(); let value: String = cmd("GET") .arg(&["deadpool/testkey"]) .queryasync(&mut conn) .await.unwrap(); asserteq!(value, "42".tostring()); } } ```

FAQ

License

Licensed under either of

at your option.