Struct lru_time_cache::LruCache
[−]
[src]
pub struct LruCache<K, V> { // some fields omitted }
Provides a Last Recently Used caching algorithm in a container which may be limited by size or time, reordered to most recently seen.
Methods
impl<K, V> LruCache<K, V> where K: PartialOrd + Ord + Clone, V: Clone
[src]
Constructor for size (capacity) based LruCache
fn with_capacity(capacity: usize) -> LruCache<K, V>
fn with_expiry_duration(time_to_live: Duration) -> LruCache<K, V>
Constructor for time based LruCache
fn with_expiry_duration_and_capacity(time_to_live: Duration, capacity: usize) -> LruCache<K, V>
Constructor for dual feature capacity, or time based LruCache
fn add(&mut self, key: K, value: V)
Add a key/value pair to cache
fn insert(&mut self, key: K, value: V) -> Option<V>
Inserts a key-value pair into the cache. If the key already had a value
present in the cache, that value is returned. Otherwise, None
is returned.
fn remove(&mut self, key: &K) -> Option<V>
Remove a key/value pair from cache
fn get(&mut self, key: &K) -> Option<&V>
Retrieve a value from cache
fn get_mut(&mut self, key: &K) -> Option<&mut V>
Retrieve a value from cache
fn check(&self, key: &K) -> bool
Check for existence of a key
fn contains_key(&self, key: &K) -> bool
fn len(&self) -> usize
Current size of cache
fn retrieve_all(&self) -> Vec<(K, V)>
fn entry(&mut self, key: K) -> Entry<K, V>
Gets the given key's corresponding entry in the map for in-place manipulation.
Trait Implementations
impl<K: Clone, V: Clone> Clone for LruCache<K, V>
[src]
fn clone(&self) -> LruCache<K, V>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more