[][src]Struct tokio_cache::AsyncCache

pub struct AsyncCache<K, V> where
    K: Hash + Eq + Clone,
    V: Clone
{ /* fields omitted */ }

A cache where reads are wait-free and where writes are asynchronous, such as it can be used within code that cannot block.

Methods

impl<K, V> AsyncCache<K, V> where
    K: Hash + Eq + Clone,
    V: Clone
[src]

pub fn new() -> Self[src]

pub fn read<BK: ?Sized>(&self, key: &BK) -> Option<V> where
    BK: Hash + Eq,
    K: Borrow<BK>, 
[src]

Reads the cached entry for the given key.

Note that this will not block.

pub async fn write<'_, F, E>(&'_ self, key: K, future: F) -> Result<V, E> where
    F: Future<Output = Result<V, E>>, 
[src]

Writes the result of the given future in the cache at entry key.

If multiple writes, concurrent or not, on the same key are issued, only one of the futures will be polled and the others will be dropped.

Trait Implementations

impl<K, V> Default for AsyncCache<K, V> where
    K: Hash + Eq + Clone + Debug,
    V: Clone + Debug
[src]

impl<K: Clone, V: Clone> Clone for AsyncCache<K, V> where
    K: Hash + Eq + Clone,
    V: Clone
[src]

impl<K, V> Debug for AsyncCache<K, V> where
    K: Hash + Eq + Clone + Debug,
    V: Clone + Debug
[src]

Auto Trait Implementations

impl<K, V> Send for AsyncCache<K, V> where
    K: Send + Sync,
    V: Send + Sync

impl<K, V> Unpin for AsyncCache<K, V>

impl<K, V> Sync for AsyncCache<K, V> where
    K: Send + Sync,
    V: Send + Sync

impl<K, V> !UnwindSafe for AsyncCache<K, V>

impl<K, V> !RefUnwindSafe for AsyncCache<K, V>

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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.

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self