memcache 0.0.14

memcached client for rust
Documentation

rust-memcache

Build Status Crates.io MIT licensed Docs

rust-memcache is a Memcached client written in pure rust.

Install:

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

[dependencies.redis]
version = "*"

Features:

  • ASCII protocal
  • Binary protocal
  • TCP connection
  • UDP connection
  • UNIX Domain socket connection
  • Automatically compress
  • Automatically serialize to JSON / msgpack etc.
  • Typed interface
  • Mutiple server support with custom key hash algorithm

Basic usage:

// create connection
let mut conn = memcache::Connection::connect("127.0.0.1:12345").unwrap();

// flush the database
conn.flush().unwrap();

// set a string value
conn.set("foo", "bar").unwrap();
// retrieve from memcached
let value: String = conn.get("foo").unwrap();
assert!(value == "bar");

// set a int value
conn.set("number", 42).unwrap();
// increment it atomic
conn.incr("number", 1);
// retrieve it as i32
let value: i32 = conn.get("number").unwrap();
assert!(value == 43);

License

MIT