[−][src]Struct memcache::Client
Fields
hash_function: fn(_: &str) -> u64
Methods
impl Client
[src]
pub fn new<C: Connectable>(target: C) -> Result<Self, MemcacheError>
[src]
please use connect
instead
pub fn connect<C: Connectable>(target: C) -> Result<Self, MemcacheError>
[src]
pub fn set_read_timeout(
&mut self,
timeout: Option<Duration>
) -> Result<(), MemcacheError>
[src]
&mut self,
timeout: Option<Duration>
) -> Result<(), MemcacheError>
Set the socket read timeout for TCP connections.
Example:
let mut client = memcache::Client::connect("memcache://localhost:12345").unwrap(); client.set_read_timeout(Some(::std::time::Duration::from_secs(3))).unwrap();
pub fn set_write_timeout(
&mut self,
timeout: Option<Duration>
) -> Result<(), MemcacheError>
[src]
&mut self,
timeout: Option<Duration>
) -> Result<(), MemcacheError>
Set the socket write timeout for TCP connections.
Example:
let mut client = memcache::Client::connect("memcache://localhost:12345?protocol=ascii").unwrap(); client.set_write_timeout(Some(::std::time::Duration::from_secs(3))).unwrap();
pub fn version(&mut self) -> Result<Vec<(String, String)>, MemcacheError>
[src]
Get the memcached server version.
Example:
let mut client = memcache::Client::connect("memcache://localhost:12345").unwrap(); client.version().unwrap();
pub fn flush(&mut self) -> Result<(), MemcacheError>
[src]
Flush all cache on memcached server immediately.
Example:
let mut client = memcache::Client::connect("memcache://localhost:12345").unwrap(); client.flush().unwrap();
pub 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::connect("memcache://localhost:12345").unwrap(); client.flush_with_delay(10).unwrap();
pub 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::connect("memcache://localhost:12345").unwrap(); let _: Option<String> = client.get("foo").unwrap();
pub 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::connect("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");
pub fn set<V: ToMemcacheValue<Stream>>(
&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::connect("memcache://localhost:12345").unwrap(); client.set("foo", "bar", 10).unwrap();
pub fn add<V: ToMemcacheValue<Stream>>(
&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::connect("memcache://localhost:12345").unwrap(); let key = "add_test"; client.delete(key).unwrap(); client.add(key, "bar", 100000000).unwrap();
pub fn replace<V: ToMemcacheValue<Stream>>(
&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::connect("memcache://localhost:12345").unwrap(); let key = "replace_test"; client.set(key, "bar", 0).unwrap(); client.replace(key, "baz", 100000000).unwrap();
pub fn append<V: ToMemcacheValue<Stream>>(
&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::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!");
pub fn prepend<V: ToMemcacheValue<Stream>>(
&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::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!");
pub fn delete(&mut self, key: &str) -> Result<bool, MemcacheError>
[src]
Delete a key from memcached server.
Example:
let mut client = memcache::Client::connect("memcache://localhost:12345").unwrap(); client.delete("foo").unwrap();
pub fn increment(
&mut self,
key: &str,
amount: u64
) -> Result<u64, MemcacheError>
[src]
&mut self,
key: &str,
amount: u64
) -> Result<u64, MemcacheError>
Increment the value with amount.
Example:
let mut client = memcache::Client::connect("memcache://localhost:12345").unwrap(); client.increment("counter", 42).unwrap();
pub fn decrement(
&mut self,
key: &str,
amount: u64
) -> Result<u64, MemcacheError>
[src]
&mut self,
key: &str,
amount: u64
) -> Result<u64, MemcacheError>
Decrement the value with amount.
Example:
let mut client = memcache::Client::connect("memcache://localhost:12345").unwrap(); client.decrement("counter", 42).unwrap();
pub fn touch(
&mut self,
key: &str,
expiration: u32
) -> Result<bool, MemcacheError>
[src]
&mut self,
key: &str,
expiration: u32
) -> Result<bool, MemcacheError>
Set a new expiration time for a exist key.
Example:
let mut 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);
pub fn stats(
&mut self
) -> Result<Vec<(String, HashMap<String, String>)>, MemcacheError>
[src]
&mut self
) -> Result<Vec<(String, HashMap<String, String>)>, MemcacheError>
Get all servers' statistics.
Example:
let mut client = memcache::Client::connect("memcache://localhost:12345").unwrap(); let stats = client.stats().unwrap();
Auto Trait Implementations
impl Sync for Client
impl Send for Client
impl Unpin for Client
impl RefUnwindSafe for Client
impl UnwindSafe for Client
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,