Struct cached::stores::SizedCache [−][src]
pub struct SizedCache<K, V> { /* fields omitted */ }
Expand description
Least Recently Used / Sized
Cache
Stores up to a specified size before beginning to evict the least recently used keys
Note: This cache is in-memory only
Implementations
method renamed to with_size
Creates a new SizedCache
with a given size limit and pre-allocated backing data
Return an iterator of keys in the current order from most to least recently used.
Return an iterator of values in the current order from most to least recently used.
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,
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,
impl<K, V> PartialEq<SizedCache<K, V>> for SizedCache<K, V> where
K: Eq + Hash + Clone,
V: PartialEq,
impl<K, V> PartialEq<SizedCache<K, V>> for SizedCache<K, V> where
K: Eq + Hash + Clone,
V: PartialEq,
Auto Trait Implementations
impl<K, V> RefUnwindSafe for SizedCache<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for SizedCache<K, V> where
K: Send,
V: Send,
impl<K, V> Sync for SizedCache<K, V> where
K: Sync,
V: Sync,
impl<K, V> Unpin for SizedCache<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for SizedCache<K, V> where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more