Struct cached::stores::SizedCache
source · pub struct SizedCache<K, V> { /* private fields */ }
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
sourceimpl<K: Hash + Eq, V> SizedCache<K, V>
impl<K: Hash + Eq, V> SizedCache<K, V>
pub fn with_capacity(size: usize) -> SizedCache<K, V>
👎Deprecated since 0.5.1: method renamed to
with_size
sourcepub fn with_size(size: usize) -> SizedCache<K, V>
pub fn with_size(size: usize) -> SizedCache<K, V>
Creates a new SizedCache
with a given size limit and pre-allocated backing data
Trait Implementations
sourceimpl<K: Hash + Eq + Clone, V> Cached<K, V> for SizedCache<K, V>
impl<K: Hash + Eq + Clone, V> Cached<K, V> for SizedCache<K, V>
sourcefn cache_remove(&mut self, k: &K) -> Option<V>
fn cache_remove(&mut self, k: &K) -> Option<V>
Remove a cached value
sourcefn cache_clear(&mut self)
fn cache_clear(&mut self)
Remove all cached values
sourcefn cache_size(&self) -> usize
fn cache_size(&self) -> usize
Return the current cache size (number of elements)
sourcefn cache_hits(&self) -> Option<u32>
fn cache_hits(&self) -> Option<u32>
Return the number of times a cached value was successfully retrieved
sourcefn cache_misses(&self) -> Option<u32>
fn cache_misses(&self) -> Option<u32>
Return the number of times a cached value was unable to be retrieved
sourcefn cache_capacity(&self) -> Option<usize>
fn cache_capacity(&self) -> Option<usize>
Return the cache capacity
sourcefn cache_lifespan(&self) -> Option<u64>
fn cache_lifespan(&self) -> Option<u64>
Return the lifespan of cached values (time to eviction)
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 + RefUnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more