[−][src]Struct tokio_cache::AsyncCache
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]
K: Hash + Eq + Clone,
V: Clone,
pub fn new() -> Self
[src]
pub fn read<BK: ?Sized>(&self, key: &BK) -> Option<V> where
BK: Hash + Eq,
K: Borrow<BK>,
[src]
BK: Hash + Eq,
K: Borrow<BK>,
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]
F: Future<Output = Result<V, E>>,
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]
K: Hash + Eq + Clone + Debug,
V: Clone + Debug,
impl<K: Clone, V: Clone> Clone for AsyncCache<K, V> where
K: Hash + Eq + Clone,
V: Clone,
[src]
K: Hash + Eq + Clone,
V: Clone,
fn clone(&self) -> AsyncCache<K, V>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<K, V> Debug for AsyncCache<K, V> where
K: Hash + Eq + Clone + Debug,
V: Clone + Debug,
[src]
K: Hash + Eq + Clone + Debug,
V: Clone + Debug,
Auto Trait Implementations
impl<K, V> Send for AsyncCache<K, V> where
K: Send + Sync,
V: Send + Sync,
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,
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]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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,
impl<T> Same<T> for T
type Output = T
Should always be Self