pub struct Client { /* private fields */ }
Expand description
Memcached client
ⓘ
use memcached::client::{Client};
use memcached::proto::{CasOperation, MultiOperation, NoReplyOperation, Operation, ProtoType};
let mut client = Client::connect(&[("tcp://127.0.0.1:11211", 1)], ProtoType::Binary).unwrap();
client.set(b"Foo", b"Bar", 0xdeadbeef, 2).unwrap();
let (value, flags) = client.get(b"Foo").unwrap();
assert_eq!(&value[..], b"Bar");
assert_eq!(flags, 0xdeadbeef);
client.set_noreply(b"key:dontreply", b"1", 0x00000001, 20).unwrap();
let (_, cas_val) = client.increment_cas(b"key:numerical", 10, 1, 20, 0).unwrap();
client.increment_cas(b"key:numerical", 1, 1, 20, cas_val).unwrap();
Implementations§
Source§impl Client
impl Client
Sourcepub fn connect<S: ToString>(svrs: &[(S, usize)], p: ProtoType) -> Result<Client>
pub fn connect<S: ToString>(svrs: &[(S, usize)], p: ProtoType) -> Result<Client>
Connect to Memcached servers
This function accept multiple servers, servers information should be represented as a array of tuples in this form
(address, weight)
.
Sourcepub fn connect_sasl<S: ToString>(
svrs: &[(S, usize)],
p: ProtoType,
username: &str,
password: &str,
) -> Result<Client>
pub fn connect_sasl<S: ToString>( svrs: &[(S, usize)], p: ProtoType, username: &str, password: &str, ) -> Result<Client>
Connect to Memcached servers that require SASL authentication
This function accept multiple servers, servers information should be represented as a array of tuples in this form
(address, weight)
.
Trait Implementations§
Source§impl CasOperation for Client
impl CasOperation for Client
fn set_cas( &mut self, key: &[u8], value: &[u8], flags: u32, expiration: u32, cas: u64, ) -> MemCachedResult<u64>
fn add_cas( &mut self, key: &[u8], value: &[u8], flags: u32, expiration: u32, ) -> MemCachedResult<u64>
fn replace_cas( &mut self, key: &[u8], value: &[u8], flags: u32, expiration: u32, cas: u64, ) -> MemCachedResult<u64>
fn get_cas(&mut self, key: &[u8]) -> MemCachedResult<(Vec<u8>, u32, u64)>
fn getk_cas( &mut self, key: &[u8], ) -> MemCachedResult<(Vec<u8>, Vec<u8>, u32, u64)>
fn increment_cas( &mut self, key: &[u8], amount: u64, initial: u64, expiration: u32, cas: u64, ) -> MemCachedResult<(u64, u64)>
fn decrement_cas( &mut self, key: &[u8], amount: u64, initial: u64, expiration: u32, cas: u64, ) -> MemCachedResult<(u64, u64)>
fn append_cas( &mut self, key: &[u8], value: &[u8], cas: u64, ) -> MemCachedResult<u64>
fn prepend_cas( &mut self, key: &[u8], value: &[u8], cas: u64, ) -> MemCachedResult<u64>
fn touch_cas( &mut self, key: &[u8], expiration: u32, cas: u64, ) -> MemCachedResult<u64>
Source§impl MultiOperation for Client
impl MultiOperation for Client
fn set_multi( &mut self, kv: BTreeMap<&[u8], (&[u8], u32, u32)>, ) -> MemCachedResult<()>
fn delete_multi(&mut self, keys: &[&[u8]]) -> MemCachedResult<()>
fn increment_multi<'a>( &mut self, kv: HashMap<&'a [u8], (u64, u64, u32)>, ) -> MemCachedResult<HashMap<&'a [u8], u64>>
fn get_multi( &mut self, keys: &[&[u8]], ) -> MemCachedResult<HashMap<Vec<u8>, (Vec<u8>, u32)>>
Source§impl NoReplyOperation for Client
impl NoReplyOperation for Client
fn set_noreply( &mut self, key: &[u8], value: &[u8], flags: u32, expiration: u32, ) -> MemCachedResult<()>
fn add_noreply( &mut self, key: &[u8], value: &[u8], flags: u32, expiration: u32, ) -> MemCachedResult<()>
fn delete_noreply(&mut self, key: &[u8]) -> MemCachedResult<()>
fn replace_noreply( &mut self, key: &[u8], value: &[u8], flags: u32, expiration: u32, ) -> MemCachedResult<()>
fn increment_noreply( &mut self, key: &[u8], amount: u64, initial: u64, expiration: u32, ) -> MemCachedResult<()>
fn decrement_noreply( &mut self, key: &[u8], amount: u64, initial: u64, expiration: u32, ) -> MemCachedResult<()>
fn append_noreply(&mut self, key: &[u8], value: &[u8]) -> MemCachedResult<()>
fn prepend_noreply(&mut self, key: &[u8], value: &[u8]) -> MemCachedResult<()>
Source§impl Operation for Client
impl Operation for Client
fn set( &mut self, key: &[u8], value: &[u8], flags: u32, expiration: u32, ) -> MemCachedResult<()>
fn add( &mut self, key: &[u8], value: &[u8], flags: u32, expiration: u32, ) -> MemCachedResult<()>
fn delete(&mut self, key: &[u8]) -> MemCachedResult<()>
fn replace( &mut self, key: &[u8], value: &[u8], flags: u32, expiration: u32, ) -> MemCachedResult<()>
fn get(&mut self, key: &[u8]) -> MemCachedResult<(Vec<u8>, u32)>
fn getk(&mut self, key: &[u8]) -> MemCachedResult<(Vec<u8>, Vec<u8>, u32)>
fn increment( &mut self, key: &[u8], amount: u64, initial: u64, expiration: u32, ) -> MemCachedResult<u64>
fn decrement( &mut self, key: &[u8], amount: u64, initial: u64, expiration: u32, ) -> MemCachedResult<u64>
fn append(&mut self, key: &[u8], value: &[u8]) -> MemCachedResult<()>
fn prepend(&mut self, key: &[u8], value: &[u8]) -> MemCachedResult<()>
fn touch(&mut self, key: &[u8], expiration: u32) -> MemCachedResult<()>
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl !Send for Client
impl !Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more