28 releases (13 breaking)

✓ Uses Rust 2018 edition

0.13.0 Oct 14, 2019
0.11.0 Jul 19, 2019
0.10.0 Feb 19, 2019
0.9.1 Sep 10, 2018
0.0.2 Nov 23, 2014

#2 in Database interfaces

Download history 3157/week @ 2019-07-01 4248/week @ 2019-07-08 3917/week @ 2019-07-15 4554/week @ 2019-07-22 4199/week @ 2019-07-29 3774/week @ 2019-08-05 4037/week @ 2019-08-12 4583/week @ 2019-08-19 4620/week @ 2019-08-26 5012/week @ 2019-09-02 4498/week @ 2019-09-09 4534/week @ 2019-09-16 5143/week @ 2019-09-23 5558/week @ 2019-09-30 4297/week @ 2019-10-07

19,299 downloads per month
Used in 83 crates (73 directly)

BSD-3-Clause

195KB
3.5K SLoC

redis-rs

Build Status crates.io

Redis-rs is a high level redis library for Rust. It provides convenient access to all Redis functionality through a very flexible but low-level API. It uses a customizable type conversion trait so that any operation can return results in just the type you are expecting. This makes for a very pleasant development experience.

The crate is called redis and you can depend on it via cargo:

[dependencies]
redis = "0.13.0"

Documentation on the library can be found at docs.rs/redis.

Note: redis-rs requires at least Rust 1.27.

Basic Operation

To open a connection you need to create a client and then to fetch a connection from it. In the future there will be a connection pool for those, currently each connection is separate and not pooled.

Many commands are implemented through the Commands trait but manual command creation is also possible.

extern crate redis;
use redis::Commands;

fn fetch_an_integer() -> redis::RedisResult<isize> {
    // connect to redis
    let client = redis::Client::open("redis://127.0.0.1/")?;
    let mut con = client.get_connection()?;
    // throw away the result, just make sure it does not fail
    let _ : () = con.set("my_key", 42)?;
    // read back the key and return it.  Because the return value
    // from the function is a result for integer this will automatically
    // convert into one.
    con.get("my_key")
}

Development

If you want to develop on the library there are a few commands provided by the makefile:

To build:

$ make

To test:

$ make test

To run benchmarks:

$ make bench

To build the docs:

$ make docs

Dependencies

~4.5MB
~99K SLoC