Crate memcache [] [src]

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 with to memcached server node:
let mut client = memcache::Client::new(vec!["memcache://127.0.0.1:12345", "memcache:///tmp/memcached.sock"]).unwrap();

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

// set a string value:
client.set("foo", "bar").unwrap();
// set a key with expiration seconds:
client.set_with_expiration("foo", "bar", 10).unwrap();

// retrieve from memcached
let value: Option<String> = client.get("foo").unwrap();
assert_eq!(value, Some(String::from("bar")));

Structs

Client
Connection

The connection acts as a TCP connection to the memcached server

Options

Enums

MemcacheError

Stands for errors raised from rust-memcache

Traits

FromMemcacheValue

determine how the value is unserialize to memcache

ToMemcacheValue

determine how the value is serialize to memcache