Struct memcache::Client [] [src]

pub struct Client {
    pub hash_function: fn(_: &str) -> u64,
    // some fields omitted
}

Fields

Methods

impl<'a> Client
[src]

[src]

[src]

Get the memcached server version.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
client.version().unwrap();

[src]

Flush all cache on memcached server immediately.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
client.flush().unwrap();

[src]

Flush all cache on memcached server with a delay seconds.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
client.flush_with_delay(10).unwrap();

[src]

Get a key from memcached server.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
let _: Option<String> = client.get("foo").unwrap();

[src]

Get multiple keys from memcached server. Using this function instead of calling get multiple times can reduce netwark workloads.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
client.set("foo", "42", 0).unwrap();
let result: std::collections::HashMap<String, String> = client.gets(vec!["foo", "bar", "baz"]).unwrap();
assert_eq!(result.len(), 1);
assert_eq!(result["foo"], "42");

[src]

Set a key with associate value into memcached server with expiration seconds.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
client.set("foo", "bar", 10).unwrap();

[src]

Add a key with associate value into memcached server with expiration seconds.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
let key = "add_test";
client.delete(key).unwrap();
client.add(key, "bar", 100000000).unwrap();

[src]

Replace a key with associate value into memcached server with expiration seconds.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
let key = "replace_test";
client.set(key, "bar", 0).unwrap();
client.replace(key, "baz", 100000000).unwrap();

[src]

Append value to the key.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
let key = "key_to_append";
client.set(key, "hello", 0).unwrap();
client.append(key, ", world!").unwrap();
let result: String = client.get(key).unwrap().unwrap();
assert_eq!(result, "hello, world!");

[src]

Prepend value to the key.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
let key = "key_to_append";
client.set(key, "world!", 0).unwrap();
client.prepend(key, "hello, ").unwrap();
let result: String = client.get(key).unwrap().unwrap();
assert_eq!(result, "hello, world!");

[src]

Delete a key from memcached server.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
client.delete("foo").unwrap();

[src]

Increment the value with amount.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
client.increment("counter", 42).unwrap();

[src]

Decrement the value with amount.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
client.decrement("counter", 42).unwrap();

[src]

Set a new expiration time for a exist key.

Example:

let mut client = memcache::Client::new("memcache://localhost:12345").unwrap();
assert_eq!(client.touch("not_exists_key", 12345).unwrap(), false);
client.set("foo", "bar", 123).unwrap();
assert_eq!(client.touch("foo", 12345).unwrap(), true);