[−][src]Trait cached::Cached
Cache operations
Required methods
pub fn cache_get(&mut self, k: &K) -> Option<&V>
[src]
Attempt to retrieve a cached value
pub fn cache_get_mut(&mut self, k: &K) -> Option<&mut V>
[src]
Attempt to retrieve a cached value with mutable access
pub fn cache_set(&mut self, k: K, v: V) -> Option<V>
[src]
Insert a key, value pair and return the previous value
pub fn cache_get_or_set_with<F: FnOnce() -> V>(&mut self, k: K, f: F) -> &mut V
[src]
Get or insert a key, value pair
pub fn cache_remove(&mut self, k: &K) -> Option<V>
[src]
Remove a cached value
pub fn cache_clear(&mut self)
[src]
Remove all cached values. Keeps the allocated memory for reuse.
pub fn cache_reset(&mut self)
[src]
Remove all cached values. Free memory and return to initial state
pub fn cache_size(&self) -> usize
[src]
Return the current cache size (number of elements)
Provided methods
pub fn cache_hits(&self) -> Option<u64>
[src]
Return the number of times a cached value was successfully retrieved
pub fn cache_misses(&self) -> Option<u64>
[src]
Return the number of times a cached value was unable to be retrieved
pub fn cache_capacity(&self) -> Option<usize>
[src]
Return the cache capacity
pub fn cache_lifespan(&self) -> Option<u64>
[src]
Return the lifespan of cached values (time to eviction)
pub fn cache_set_lifespan(&mut self, _seconds: u64) -> Option<u64>
[src]
Set the lifespan of cached values, returns the old value
Implementations on Foreign Types
impl<K: Hash + Eq, V> Cached<K, V> for HashMap<K, V>
[src]
pub fn cache_get(&mut self, k: &K) -> Option<&V>
[src]
pub fn cache_get_mut(&mut self, k: &K) -> Option<&mut V>
[src]
pub fn cache_get_or_set_with<F: FnOnce() -> V>(
&mut self,
key: K,
f: F
) -> &mut V
[src]
&mut self,
key: K,
f: F
) -> &mut V
pub fn cache_set(&mut self, k: K, v: V) -> Option<V>
[src]
pub fn cache_remove(&mut self, k: &K) -> Option<V>
[src]
pub fn cache_clear(&mut self)
[src]
pub fn cache_reset(&mut self)
[src]
pub fn cache_size(&self) -> usize
[src]
Implementors
impl<K: Hash + Eq + Clone, V> Cached<K, V> for SizedCache<K, V>
[src]
pub fn cache_get(&mut self, key: &K) -> Option<&V>
[src]
pub fn cache_get_mut(&mut self, key: &K) -> Option<&mut V>
[src]
pub fn cache_set(&mut self, key: K, val: V) -> Option<V>
[src]
pub fn cache_get_or_set_with<F: FnOnce() -> V>(
&mut self,
key: K,
f: F
) -> &mut V
[src]
&mut self,
key: K,
f: F
) -> &mut V
pub fn cache_remove(&mut self, k: &K) -> Option<V>
[src]
pub fn cache_clear(&mut self)
[src]
pub fn cache_reset(&mut self)
[src]
pub fn cache_size(&self) -> usize
[src]
pub fn cache_hits(&self) -> Option<u64>
[src]
pub fn cache_misses(&self) -> Option<u64>
[src]
pub fn cache_capacity(&self) -> Option<usize>
[src]
impl<K: Hash + Eq + Clone, V> Cached<K, V> for TimedSizedCache<K, V>
[src]
pub fn cache_get(&mut self, key: &K) -> Option<&V>
[src]
pub fn cache_get_mut(&mut self, key: &K) -> Option<&mut V>
[src]
pub fn cache_get_or_set_with<F: FnOnce() -> V>(
&mut self,
key: K,
f: F
) -> &mut V
[src]
&mut self,
key: K,
f: F
) -> &mut V
pub fn cache_set(&mut self, key: K, val: V) -> Option<V>
[src]
pub fn cache_remove(&mut self, k: &K) -> Option<V>
[src]
pub fn cache_clear(&mut self)
[src]
pub fn cache_reset(&mut self)
[src]
pub fn cache_size(&self) -> usize
[src]
pub fn cache_hits(&self) -> Option<u64>
[src]
pub fn cache_misses(&self) -> Option<u64>
[src]
pub fn cache_capacity(&self) -> Option<usize>
[src]
pub fn cache_lifespan(&self) -> Option<u64>
[src]
pub fn cache_set_lifespan(&mut self, seconds: u64) -> Option<u64>
[src]
impl<K: Hash + Eq, V> Cached<K, V> for TimedCache<K, V>
[src]
pub fn cache_get(&mut self, key: &K) -> Option<&V>
[src]
pub fn cache_get_mut(&mut self, key: &K) -> Option<&mut V>
[src]
pub fn cache_get_or_set_with<F: FnOnce() -> V>(
&mut self,
key: K,
f: F
) -> &mut V
[src]
&mut self,
key: K,
f: F
) -> &mut V
pub fn cache_set(&mut self, key: K, val: V) -> Option<V>
[src]
pub fn cache_remove(&mut self, k: &K) -> Option<V>
[src]
pub fn cache_clear(&mut self)
[src]
pub fn cache_reset(&mut self)
[src]
pub fn cache_size(&self) -> usize
[src]
pub fn cache_hits(&self) -> Option<u64>
[src]
pub fn cache_misses(&self) -> Option<u64>
[src]
pub fn cache_lifespan(&self) -> Option<u64>
[src]
pub fn cache_set_lifespan(&mut self, seconds: u64) -> Option<u64>
[src]
impl<K: Hash + Eq, V> Cached<K, V> for UnboundCache<K, V>
[src]
pub fn cache_get(&mut self, key: &K) -> Option<&V>
[src]
pub fn cache_get_mut(&mut self, key: &K) -> Option<&mut V>
[src]
pub fn cache_set(&mut self, key: K, val: V) -> Option<V>
[src]
pub fn cache_get_or_set_with<F: FnOnce() -> V>(
&mut self,
key: K,
f: F
) -> &mut V
[src]
&mut self,
key: K,
f: F
) -> &mut V