Skip to content
A Rust client/server library for Redis
Rust
Branch: master
Clone or download

Latest commit

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Chan::new renamed to channel() Mar 17, 2014
.gitignore Use rustpkg only. gitignore Jan 8, 2014
.travis.yml Use compile target as build is a directory Jan 8, 2014
LICENSE-MIT Add license, update doc Jan 3, 2014
Makefile Adapt to the ioerror changes. Feb 15, 2014
README.md Implement incr(). Fix get_int() Jan 14, 2014

README.md

rust-redis Build Status

A Rust client/server library for Redis.

Quickstart

extern mod redis = "redis#0.1";

fn main() {
  let mut redis = redis::Client::new("127.0.0.1:6379");

  redis.set_int("counter", 1);
  redis.set("key", "Hello");

  redis.incr("counter");

  let counter = redis.get_int("counter").unwrap();
  println!("counter = {}", counter);

  let key = redis.get_str("key").unwrap();
  println!("key = {}", key);

  match redis.get("key") {
    redis::Nil => {
      println!("Key not found")
    }
    redis::Data(ref s) => {
      println!("{:?}", std::str::from_utf8(*s))
    }
    _ => { fail!() }
  }
}

For a simple redis server implementation which supports GET/SET commands see examples/server/main.rs.

Performance

I did some early performance benchmarks with rust-0.9 and compared it against redis-benchmark.

redis-benchmark -n 100000 -c 1 -t set # ~18500 reqs/sec
redis-benchmark -n 100000 -c 2 -t set # ~27000 reqs/sec
redis-benchmark -n 100000 -c 4 -t set # ~36000 reqs/sec
redis-benchmark -n 100000 -c 8 -t set # ~44000 reqs/sec

./bin/bench 1 100000 # ~19500 reqs/sec
./bin/bench 2 100000 # ~19100 reqs/sec
./bin/bench 4 100000 # ~18800 reqs/sec
./bin/bench 8 100000 # ~18000 reqs/sec

At this simple benchmark, rust-redis consistently shows about 18000 requests per second regardless of concurrency. I think this is because the way scheduling works. Using native threads would probably lead to the same performance as redis-benchmark.

License

rust-redis is under the MIT license, see LICENSE-MIT for details.

You can’t perform that action at this time.