Skip to content

YushiOMOTE/redis-ac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
}

About

Asynchronous version of `redis::Commands` trait.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages