Struct rsmc_core::client::Client[][src]

pub struct Client<C: Connection, P: Compressor> { /* fields omitted */ }

A client manages connections to every node in a memcached cluster using consistent hashing to decide which connection to use based on the key.

Implementations

impl<C: Connection, P: Compressor> Client<C, P>[src]

pub async fn new(config: ClientConfig<P>) -> Result<Self, Error>[src]

Create a new client using the client config provided.

pub async fn get<K: AsRef<[u8]>, V: DeserializeOwned>(
    &mut self,
    key: K
) -> Result<Option<V>, Error>
[src]

Get a single value from memcached. Returns None when the key is not found (i.e., a miss).

pub async fn get_multi<'a, K: AsRef<[u8]>, V: DeserializeOwned>(
    &mut self,
    keys: &[K]
) -> BulkGetResponse<V>
[src]

Get multiple values from memcached at once. On success, it returns a tuple of (ok, err) responses. The error responses can be treated as misses, but should be logged for visibility. Lots of errors could be indicative of a serious problem.

pub async fn set<K: AsRef<[u8]>, V: Serialize + ?Sized>(
    &mut self,
    key: K,
    data: &V,
    expire: u32
) -> Result<(), Error>
[src]

Set a single key/value pair in memcached to expire at the desired time. A value of 0 means “never expire”, but the value could still be evicted by the LRU cache. Important: if expire is set to more than 30 days in the future, then memcached will treat it as a unix timestamp instead of a duration.

pub async fn set_multi<'a, V: Serialize, K: AsRef<[u8]> + Eq + Hash>(
    &mut self,
    data: HashMap<K, V>,
    expire: u32
) -> BulkUpdateResponse
[src]

Set multiple key/value pairs in memcached to expire at the desired time. A value of 0 means “never expire”, but the value could still be evicted by the LRU cache. Important: if expire is set to more than 30 days in the future, then memcached will treat it as a unix timestamp instead of a duration.

pub async fn delete<K: AsRef<[u8]>>(&mut self, key: K) -> Result<(), Error>[src]

Delete a key from memcached. Does nothing if the key is not set.

pub async fn delete_multi<K: AsRef<[u8]>>(
    &mut self,
    keys: &[K]
) -> BulkUpdateResponse
[src]

Delete multiple keys from memcached. Does nothing when a key is unset.

Trait Implementations

impl<C: Clone + Connection, P: Clone + Compressor> Clone for Client<C, P>[src]

impl<C: Debug + Connection, P: Debug + Compressor> Debug for Client<C, P>[src]

impl<C, P> Manager<Client<C, P>, Error> for ClientConfig<P> where
    C: Connection,
    P: Compressor
[src]

Auto Trait Implementations

impl<C, P> RefUnwindSafe for Client<C, P> where
    C: RefUnwindSafe,
    P: RefUnwindSafe

impl<C, P> Send for Client<C, P>

impl<C, P> Sync for Client<C, P>

impl<C, P> Unpin for Client<C, P> where
    C: Unpin,
    P: Unpin

impl<C, P> UnwindSafe for Client<C, P> where
    C: UnwindSafe,
    P: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.