21 releases

0.9.0 Aug 8, 2018
0.8.0 Dec 26, 2016
0.7.1 Dec 16, 2016
0.7.0 Jul 23, 2016
0.0.2 Nov 23, 2014

#10 in Database interfaces

Download history 637/week @ 2018-06-22 777/week @ 2018-06-29 630/week @ 2018-07-06 698/week @ 2018-07-13 875/week @ 2018-07-20 924/week @ 2018-07-27 747/week @ 2018-08-03 914/week @ 2018-08-10 1103/week @ 2018-08-17 1153/week @ 2018-08-24 1258/week @ 2018-08-31 1124/week @ 2018-09-07 1264/week @ 2018-09-14

3,012 downloads per month
Used in 50 crates (47 directly)

BSD-3-Clause

171KB
3K 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.9.0"

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

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 = try!(redis::Client::open("redis://127.0.0.1/"));
    let con = try!(client.get_connection());
    // throw away the result, just make sure it does not fail
    let _ : () = try!(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

~8.5MB
~204K SLoC