Trait cached::Cached[][src]

pub trait Cached<K, V> {
Show 14 methods fn cache_get(&mut self, k: &K) -> Option<&V>;
fn cache_get_mut(&mut self, k: &K) -> Option<&mut V>;
fn cache_set(&mut self, k: K, v: V) -> Option<V>;
fn cache_get_or_set_with<F: FnOnce() -> V>(&mut self, k: K, f: F) -> &mut V;
fn cache_remove(&mut self, k: &K) -> Option<V>;
fn cache_clear(&mut self);
fn cache_reset(&mut self);
fn cache_size(&self) -> usize; fn cache_reset_metrics(&mut self) { ... }
fn cache_hits(&self) -> Option<u64> { ... }
fn cache_misses(&self) -> Option<u64> { ... }
fn cache_capacity(&self) -> Option<usize> { ... }
fn cache_lifespan(&self) -> Option<u64> { ... }
fn cache_set_lifespan(&mut self, _seconds: u64) -> Option<u64> { ... }
}
Expand description

Cache operations

Required methods

Attempt to retrieve a cached value

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

Return the current cache size (number of elements)

Provided methods

Reset misses/hits counters

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

Implementations on Foreign Types

Implementors