Struct cached::stores::SizedCache [−][src]
pub struct SizedCache<K, V> { /* fields omitted */ }
Least Recently Used / Sized
Cache
Stores up to a specified size before beginning to evict the least recently used keys
Methods
impl<K: Hash + Eq, V> SizedCache<K, V>
[src]
impl<K: Hash + Eq, V> SizedCache<K, V>
pub fn with_capacity(size: usize) -> SizedCache<K, V>
[src]
pub fn with_capacity(size: usize) -> SizedCache<K, V>
Deprecated since 0.5.1
: method renamed to with_size
pub fn with_size(size: usize) -> SizedCache<K, V>
[src]
pub fn with_size(size: usize) -> SizedCache<K, V>
Creates a new SizedCache
with a given size limit and pre-allocated backing data
pub fn key_order(&self) -> Iter<K>
[src]
pub fn key_order(&self) -> Iter<K>
Return an iterator of keys in the current order from most to least recently used.
Trait Implementations
impl<K: Hash + Eq + Clone, V> Cached<K, V> for SizedCache<K, V>
[src]
impl<K: Hash + Eq + Clone, V> Cached<K, V> for SizedCache<K, V>
fn cache_get(&mut self, key: &K) -> Option<&V>
[src]
fn cache_get(&mut self, key: &K) -> Option<&V>
Attempt to retrieve a cached value
fn cache_set(&mut self, key: K, val: V)
[src]
fn cache_set(&mut self, key: K, val: V)
Insert a key, value pair
fn cache_size(&self) -> usize
[src]
fn cache_size(&self) -> usize
Return the current cache size (number of elements)
fn cache_hits(&self) -> Option<u32>
[src]
fn cache_hits(&self) -> Option<u32>
Return the number of times a cached value was successfully retrieved
fn cache_misses(&self) -> Option<u32>
[src]
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>
[src]
fn cache_capacity(&self) -> Option<usize>
Return the cache capacity
fn cache_lifespan(&self) -> Option<u64>
[src]
fn cache_lifespan(&self) -> Option<u64>
Return the lifespan of cached values (time to eviction)
Auto Trait Implementations
impl<K, V> Send for SizedCache<K, V> where
K: Send,
V: Send,
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> Sync for SizedCache<K, V> where
K: Sync,
V: Sync,