Struct cached::UnboundCache [−][src]
pub struct UnboundCache<K, V> { /* fields omitted */ }
Expand description
Default unbounded cache
This cache has no size limit or eviction policy.
Note: This cache is in-memory only
Implementations
Creates an empty UnboundCache
Creates an empty UnboundCache
with a given pre-allocated capacity
Trait Implementations
Attempt to retrieve a cached value with mutable access
Insert a key, value pair and return the previous value
Get or insert a key, value pair
Remove a cached value
Remove all cached values. Keeps the allocated memory for reuse.
Remove all cached values. Free memory and return to initial state
Reset misses/hits counters
Return the current cache size (number of elements)
Return the number of times a cached value was successfully retrieved
Return the number of times a cached value was unable to be retrieved
Return the cache capacity
Return the lifespan of cached values (time to eviction)
Set the lifespan of cached values, returns the old value
fn get_or_set_with<'life0, 'async_trait, F, Fut>(
&'life0 mut self,
key: K,
f: F
) -> Pin<Box<dyn Future<Output = &mut V> + Send + 'async_trait>> where
V: Send,
F: FnOnce() -> Fut + Send,
Fut: Future<Output = V> + Send,
F: 'async_trait,
Fut: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn try_get_or_set_with<'life0, 'async_trait, F, Fut, E>(
&'life0 mut self,
key: K,
f: F
) -> Pin<Box<dyn Future<Output = Result<&mut V, E>> + Send + 'async_trait>> where
V: Send,
F: FnOnce() -> Fut + Send,
Fut: Future<Output = Result<V, E>> + Send,
F: 'async_trait,
Fut: 'async_trait,
E: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
impl<K, V> PartialEq<UnboundCache<K, V>> for UnboundCache<K, V> where
K: Eq + Hash,
V: PartialEq,
impl<K, V> PartialEq<UnboundCache<K, V>> for UnboundCache<K, V> where
K: Eq + Hash,
V: PartialEq,
Auto Trait Implementations
impl<K, V> RefUnwindSafe for UnboundCache<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for UnboundCache<K, V> where
K: Send,
V: Send,
impl<K, V> Sync for UnboundCache<K, V> where
K: Sync,
V: Sync,
impl<K, V> Unpin for UnboundCache<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for UnboundCache<K, V> where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more