Struct memcache::Client[][src]

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

Fields

hash_function: fn(_: &str) -> u64

Implementations

👎 Deprecated since 0.10.0:

please use connect instead

Set the socket read timeout for TCP connections.

Example:

let client = memcache::Client::connect("memcache://localhost:12345").unwrap();
client.set_read_timeout(Some(::std::time::Duration::from_secs(3))).unwrap();

Set the socket write timeout for TCP connections.

Example:

let client = memcache::Client::connect("memcache://localhost:12345?protocol=ascii").unwrap();
client.set_write_timeout(Some(::std::time::Duration::from_secs(3))).unwrap();

Get the memcached server version.

Example:

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

Flush all cache on memcached server immediately.

Example:

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

Flush all cache on memcached server with a delay seconds.

Example:

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

Get a key from memcached server.

Example:

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

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

Example:

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

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

Example:

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

Compare and swap a key with the associate value into memcached server with expiration seconds. cas_id should be obtained from a previous gets call.

Example:

use std::collections::HashMap;
let client = memcache::Client::connect("memcache://localhost:12345").unwrap();
client.set("foo", "bar", 10).unwrap();
let result: HashMap<String, (Vec<u8>, u32, Option<u64>)> = client.gets(&["foo"]).unwrap();
let (_, _, cas) = result.get("foo").unwrap();
let cas = cas.unwrap();
assert_eq!(true, client.cas("foo", "bar2", 10, cas).unwrap());

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

Example:

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

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

Example:

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

Append value to the key.

Example:

let client = memcache::Client::connect("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!");

Prepend value to the key.

Example:

let client = memcache::Client::connect("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!");

Delete a key from memcached server.

Example:

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

Increment the value with amount.

Example:

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

Decrement the value with amount.

Example:

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

Set a new expiration time for a exist key.

Example:

let client = memcache::Client::connect("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);

Get all servers’ statistics.

Example:

let client = memcache::Client::connect("memcache://localhost:12345").unwrap();
let stats = client.stats().unwrap();

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.