#redis #database

redis-ac

Asynchronuos commands helper for redis-rs

4 releases

✓ Uses Rust 2018 edition

0.2.1 Nov 23, 2019
0.2.0 Nov 22, 2019
0.1.1 Nov 23, 2019
0.1.0 Nov 16, 2019

#418 in Database interfaces

Download history 50/week @ 2019-11-30 82/week @ 2019-12-07 30/week @ 2019-12-14 49/week @ 2019-12-21 16/week @ 2019-12-28 80/week @ 2020-01-04 142/week @ 2020-01-11 157/week @ 2020-01-18 97/week @ 2020-01-25 49/week @ 2020-02-01 51/week @ 2020-02-08 129/week @ 2020-02-15 101/week @ 2020-02-22 55/week @ 2020-02-29 91/week @ 2020-03-07 60/week @ 2020-03-14

104 downloads per month

BSD-3-Clause

49KB
638 lines

redis-ac

Asynchronous version of redis::Commands trait.

Latest version Documentation License Actions Status

Get/set

use futures::prelude::*;
use redis_ac::Commands;

fn main() {
    let client = redis::Client::open("redis://127.0.0.1/").unwrap();

    let f = client
        .get_async_connection()
        .and_then(|con| {
            con.set("key", "value")
                .and_then(|(con, s): (_, String)| {
                    assert_eq!(s, "OK");
                    con.get("key")
                })
                .map(|(_, s): (_, String)| {
                    assert_eq!(s, "value");
                })
        })
        .map_err(|e| panic!("{}", e));

    tokio::run(f);
}

Scan

use futures::prelude::*;
use redis_ac::Commands;

fn main() {
    let client = redis::Client::open("redis://127.0.0.1/").unwrap();

    let f = client
        .get_shared_async_connection()
        .and_then(|con| {
            con.scan_match("key*")
                .filter_map(|(_, item)| item)
                .for_each(|item: String| {
                    // Here we get items.
                    println!("{}", item);
                    Ok(())
                })
        }).map_err(|e| panic!("{}", e));

    tokio::run(f);
}

Dependencies

~4.5MB
~98K SLoC