Trait cached::Cached

source ·
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_remove(&mut self, k: &K) -> Option<V>;
    fn cache_clear(&mut self);
    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> { ... }
}
Expand description

Cache operations

Required Methods

Attempt to retrieve a cached value

Insert a key, value pair

Remove a cached value

Remove all cached values

Return the current cache size (number of elements)

Provided Methods

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)

Implementors