memcache 0.2.0

memcached client for rust

rust-memcache

Build Status Coverage 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]
memcache = "*"

Features:

  • 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 client = memcache::Client::connect("memcache://127.0.0.1:12345").unwrap();
// or using unix domain socket:
// let mut client = memcache::Client::connect("memcache:///tmp/memcached.sock").unwrap();

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

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

License

MIT