Struct cached::stores::TimedCache [−][src]
pub struct TimedCache<K, V> { /* fields omitted */ }
Expand description
Cache store bound by time
Values are timestamped when inserted and are evicted if expired at time of retrieval.
Note: This cache is in-memory only
Implementations
Creates a new TimedCache
with a specified lifespan
Creates a new TimedCache
with a specified lifespan and
cache-store with the specified pre-allocated capacity
Trait Implementations
Attempt to retrieve a cached value with mutable access
Get or insert a key, value pair
Insert a key, value pair and return the previous value
Remove a cached value
Remove all cached values. Keeps the allocated memory for reuse.
Reset misses/hits counters
Remove all cached values. Free memory and return to initial state
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 lifespan of cached values (time to eviction)
Set the lifespan of cached values, returns the old value
Return the cache capacity
fn get_or_set_with<'life0, 'async_trait, F, Fut>(
&'life0 mut self,
k: 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,
k: 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,
Auto Trait Implementations
impl<K, V> RefUnwindSafe for TimedCache<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for TimedCache<K, V> where
K: Send,
V: Send,
impl<K, V> Sync for TimedCache<K, V> where
K: Sync,
V: Sync,
impl<K, V> Unpin for TimedCache<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for TimedCache<K, V> where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more