Struct memcache::Client
[−]
[src]
pub struct Client { pub hash_function: fn(_: &str) -> u64, // some fields omitted }
Fields
hash_function: fn(_: &str) -> u64
Methods
impl<'a> Client
[src]
fn new<C: Connectable<'a>>(target: C) -> Result<Self, MemcacheError>
[src]
fn version(&mut self) -> Result<Vec<(String, String)>, MemcacheError>
[src]
Get the memcached server version.
Example:
let mut client = memcache::Client::new("memcache://localhost:12345").unwrap(); client.version().unwrap();
fn flush(&mut self) -> Result<(), MemcacheError>
[src]
Flush all cache on memcached server immediately.
Example:
let mut client = memcache::Client::new("memcache://localhost:12345").unwrap(); client.flush().unwrap();
fn flush_with_delay(&mut self, delay: u32) -> Result<(), MemcacheError>
[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();
fn get<V: FromMemcacheValue>(
&mut self,
key: &str
) -> Result<Option<V>, MemcacheError>
[src]
&mut self,
key: &str
) -> Result<Option<V>, MemcacheError>
Get a key from memcached server.
Example:
let mut client = memcache::Client::new("memcache://localhost:12345").unwrap(); let _: Option<String> = client.get("foo").unwrap();
fn gets<V: FromMemcacheValue>(
&mut self,
keys: Vec<&str>
) -> Result<HashMap<String, V>, MemcacheError>
[src]
&mut self,
keys: Vec<&str>
) -> Result<HashMap<String, V>, MemcacheError>
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"); let result: std::collections::HashMap<String, String> = client.gets(vec!["foo", "bar", "baz"]).unwrap(); assert_eq!(result.len(), 1); assert_eq!(result["foo"], "42");
fn set<V: ToMemcacheValue<Connection>>(
&mut self,
key: &str,
value: V
) -> Result<(), MemcacheError>
[src]
&mut self,
key: &str,
value: V
) -> Result<(), MemcacheError>
Set a key with associate value into memcached server.
Example:
let mut client = memcache::Client::new("memcache://localhost:12345").unwrap(); client.set("foo", "bar").unwrap();
fn set_with_expiration<V: ToMemcacheValue<Connection>>(
&mut self,
key: &str,
value: V,
expiration: u32
) -> Result<(), MemcacheError>
[src]
&mut self,
key: &str,
value: V,
expiration: u32
) -> Result<(), MemcacheError>
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_with_expiration("foo", "bar", 10).unwrap();
fn add<V: ToMemcacheValue<Connection>>(
&mut self,
key: &str,
value: V
) -> Result<(), MemcacheError>
[src]
&mut self,
key: &str,
value: V
) -> Result<(), MemcacheError>
Add a key with associate value into memcached server.
Example:
let mut client = memcache::Client::new("memcache://localhost:12345").unwrap(); let key = "add_test"; client.delete(key).unwrap(); client.add(key, "bar").unwrap();
fn add_with_expiration<V: ToMemcacheValue<Connection>>(
&mut self,
key: &str,
value: V,
expiration: u32
) -> Result<(), MemcacheError>
[src]
&mut self,
key: &str,
value: V,
expiration: u32
) -> Result<(), MemcacheError>
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_with_expiration_test"; client.delete(key).unwrap(); client.add_with_expiration(key, "bar", 100000000).unwrap();
fn replace<V: ToMemcacheValue<Connection>>(
&mut self,
key: &str,
value: V
) -> Result<(), MemcacheError>
[src]
&mut self,
key: &str,
value: V
) -> Result<(), MemcacheError>
Replace a key with associate value into memcached server.
Example:
let mut client = memcache::Client::new("memcache://localhost:12345").unwrap(); let key = "replace_test"; client.set(key, "bar").unwrap(); client.replace(key, "baz").unwrap();
fn replace_with_expiration<V: ToMemcacheValue<Connection>>(
&mut self,
key: &str,
value: V,
expiration: u32
) -> Result<(), MemcacheError>
[src]
&mut self,
key: &str,
value: V,
expiration: u32
) -> Result<(), MemcacheError>
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_with_expiration_test"; client.set(key, "bar").unwrap(); client.replace_with_expiration(key, "baz", 100000000).unwrap();
fn append<V: ToMemcacheValue<Connection>>(
&mut self,
key: &str,
value: V
) -> Result<(), MemcacheError>
[src]
&mut self,
key: &str,
value: V
) -> Result<(), MemcacheError>
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").unwrap(); client.append(key, ", world!").unwrap(); let result: String = client.get(key).unwrap().unwrap(); assert_eq!(result, "hello, world!");
fn prepend<V: ToMemcacheValue<Connection>>(
&mut self,
key: &str,
value: V
) -> Result<(), MemcacheError>
[src]
&mut self,
key: &str,
value: V
) -> Result<(), MemcacheError>
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!").unwrap(); client.prepend(key, "hello, ").unwrap(); let result: String = client.get(key).unwrap().unwrap(); assert_eq!(result, "hello, world!");
fn delete(&mut self, key: &str) -> Result<bool, MemcacheError>
[src]
Delete a key from memcached server.
Example:
let mut client = memcache::Client::new("memcache://localhost:12345").unwrap(); client.delete("foo").unwrap();
fn increment(&mut self, key: &str, amount: u64) -> Result<u64, MemcacheError>
[src]
Increment the value with amount.
Example:
let mut client = memcache::Client::new("memcache://localhost:12345").unwrap(); client.increment("counter", 42).unwrap();
fn decrement(&mut self, key: &str, amount: u64) -> Result<u64, MemcacheError>
[src]
Decrement the value with amount.
Example:
let mut client = memcache::Client::new("memcache://localhost:12345").unwrap(); client.decrement("counter", 42).unwrap();