[][src]Crate deadpool_redis

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

FeatureDescriptionExtra dependenciesDefault
configEnable support for config crateconfig, serde/deriveyes

Example

use deadpool_redis::{cmd, Config};
use redis::FromRedisValue;

#[tokio::main]
async fn main() {
    let cfg = Config::from_env("REDIS").unwrap();
    let pool = cfg.create_pool().unwrap();
    {
        let mut conn = pool.get().await.unwrap();
        cmd("SET")
            .arg(&["deadpool/test_key", "42"])
            .execute_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());
    }
}

License

Licensed under either of

at your option.

Structs

Cmd

Wrapper for redis::Cmd which makes it compatible with the query_async method which takes a ConnectionLike as argument.

Config

Configuration object. By enabling the config feature you can read the configuration using the config crate.

ConnectionWrapper

A type alias for using deadpool::Object with redis

Manager

The manager for creating and recyling lapin connections

Pipeline

Wrapper for redis::Cmd which makes it compatible with the query_async method which takes a ConnectionLike as argument.

Functions

cmd

Shortcut function to creating a command with a single argument.

pipe

Shortcut for creating a new pipeline.

Type Definitions

Pool

A type alias for using deadpool::Pool with redis

PoolError

A type alias for using deadpool::PoolError with redis