Crate ciseaux_client

Source
Expand description

This is a simple asynchronous Redis Pool, currently only supports a connection pool to a Single Redis instance, and will probably provide Cluster support later. If you want to understand how to use it, see examples and/or CiseauxSingle struct.

The library currently supports tokio only (Because of redis-rs, async-std support is coming), and require at least Rust 1.39

[dependencies]
ciseaux_client = "0.3"

§Example

Create a connection pool default settings and the provided redis::Client (from redis-rs)

use redis::{Client, Cmd};
use ciseaux_client::CiseauxSingle;

#[tokio::main]
async fn main() {
    let redis_client = Client::open("redis://127.0.0.1:6379").unwrap();
    let db_pool = CiseauxSingle::new(redis_client).await.expect("Failed to create Pool");
    // You can safely share CiseauxSingle between threads
    // since it use Arcs and Mutexes under the hood)
    let res = match db_pool.query::<_, Option<String>>(&redis::Cmd::get("hello")).await {
        Ok(v) => v,
        Err(e) => return,// Handle Error
    };
    let hello = match res {
        Some(v) => v,
        None => return,// Handle Nil value
    };
    println!("{}", hello);
}

Re-exports§

pub use redis;

Structs§

CiseauxSingle
A connections pool to a single Redis instance
SingleInit
An Init Struct to create a customized CiseauxSingle connections pool. This is like a Builder, but using public fields instead of functions

Enums§

ConnectionsCount
To change the default pool size
ReconnectBehavior
To change the default behavior of the pool on network/io error.

Traits§

QueryAble
A trait that allow to have a single CiseauxSingle query, and not a query_x per redis commands types (redis::Cmd and redis::Pipeline). Implemented for redis::Cmd and redis::Pipeline (including &, and &mut)