Trait cached::Cached
[−]
[src]
pub trait Cached<K, V> { fn cache_get(&mut self, k: &K) -> Option<&V>; fn cache_set(&mut self, k: K, v: V); fn cache_size(&self) -> usize; fn cache_hits(&self) -> Option<u32> { ... } fn cache_misses(&self) -> Option<u32> { ... } fn cache_capacity(&self) -> Option<usize> { ... } fn cache_lifespan(&self) -> Option<u64> { ... } }
Cache operations
Required Methods
fn cache_get(&mut self, k: &K) -> Option<&V>
Attempt to retrieve a cached value
fn cache_set(&mut self, k: K, v: V)
Insert a key, value pair
fn cache_size(&self) -> usize
Return the current cache size (number of elements)
Provided Methods
fn cache_hits(&self) -> Option<u32>
Return the number of times a cached value was successfully retrieved
fn cache_misses(&self) -> Option<u32>
Return the number of times a cached value was unable to be retrieved
fn cache_capacity(&self) -> Option<usize>
Return the cache capacity
fn cache_lifespan(&self) -> Option<u64>
Return the lifespan of cached values (time to eviction)
Implementors
impl<K: Hash + Eq, V> Cached<K, V> for UnboundCache<K, V>
impl<K: Hash + Eq + Clone, V> Cached<K, V> for SizedCache<K, V>
impl<K: Hash + Eq, V> Cached<K, V> for TimedCache<K, V>