pub struct Protocol<S> { /* private fields */ }Expand description
Memcache ASCII protocol implementation.
Implementations§
Source§impl<S> Protocol<S>
impl<S> Protocol<S>
Sourcepub async fn get<K: AsRef<[u8]>>(&mut self, key: K) -> Result<Vec<u8>, Error>
pub async fn get<K: AsRef<[u8]>>(&mut self, key: K) -> Result<Vec<u8>, Error>
Returns the value for given key as bytes. If the value doesn’t exist, ErrorKind::NotFound is returned.
Sourcepub async fn get_multi<K: AsRef<[u8]>>(
&mut self,
keys: &[K],
) -> Result<HashMap<String, Vec<u8>>, Error>
pub async fn get_multi<K: AsRef<[u8]>>( &mut self, keys: &[K], ) -> Result<HashMap<String, Vec<u8>>, Error>
Returns values for multiple keys in a single call as a HashMap from keys to found values.
If a key is not present in memcached it will be absent from returned map.
Sourcepub async fn get_prefix<K: Display>(
&mut self,
key_prefix: K,
limit: Option<usize>,
) -> Result<HashMap<String, Vec<u8>>, Error>
pub async fn get_prefix<K: Display>( &mut self, key_prefix: K, limit: Option<usize>, ) -> Result<HashMap<String, Vec<u8>>, Error>
Get up to limit keys which match the given prefix. Returns a HashMap from keys to found values.
This is not part of the Memcached standard, but some servers implement it nonetheless.
Sourcepub async fn add<K: Display>(
&mut self,
key: K,
val: &[u8],
expiration: u32,
) -> Result<(), Error>
pub async fn add<K: Display>( &mut self, key: K, val: &[u8], expiration: u32, ) -> Result<(), Error>
Add a key. If the value exists, ErrorKind::AlreadyExists is returned.
Sourcepub async fn set<K: Display>(
&mut self,
key: K,
val: &[u8],
expiration: u32,
) -> Result<(), Error>
pub async fn set<K: Display>( &mut self, key: K, val: &[u8], expiration: u32, ) -> Result<(), Error>
Set key to given value and don’t wait for response.
Sourcepub async fn append<K: Display>(
&mut self,
key: K,
val: &[u8],
) -> Result<(), Error>
pub async fn append<K: Display>( &mut self, key: K, val: &[u8], ) -> Result<(), Error>
Append bytes to the value in memcached and don’t wait for response.
Sourcepub async fn delete<K: Display>(&mut self, key: K) -> Result<(), Error>
pub async fn delete<K: Display>(&mut self, key: K) -> Result<(), Error>
Delete a key and don’t wait for response.
Sourcepub async fn version(&mut self) -> Result<String, Error>
pub async fn version(&mut self) -> Result<String, Error>
Return the version of the remote server.
Sourcepub async fn increment<K: AsRef<[u8]>>(
&mut self,
key: K,
amount: u64,
) -> Result<u64, Error>
pub async fn increment<K: AsRef<[u8]>>( &mut self, key: K, amount: u64, ) -> Result<u64, Error>
Increment a specific integer stored with a key by a given value. If the value doesn’t exist, ErrorKind::NotFound is returned.
Otherwise the new value is returned
Sourcepub async fn decrement<K: AsRef<[u8]>>(
&mut self,
key: K,
amount: u64,
) -> Result<u64, Error>
pub async fn decrement<K: AsRef<[u8]>>( &mut self, key: K, amount: u64, ) -> Result<u64, Error>
Decrement a specific integer stored with a key by a given value. If the value doesn’t exist, ErrorKind::NotFound is returned.
Otherwise the new value is returned
Sourcepub async fn gets_cas<K: AsRef<[u8]>>(
&mut self,
key: K,
) -> Result<(Vec<u8>, u64), Error>
pub async fn gets_cas<K: AsRef<[u8]>>( &mut self, key: K, ) -> Result<(Vec<u8>, u64), Error>
Call gets to also return CAS id, which can be used to run a second CAS command