Struct lru_time_cache::LruCache [−][src]
pub struct LruCache<Key, Value> { /* fields omitted */ }
Expand description
Implementation of LRU cache.
Implementations
Constructor for capacity based LruCache
.
Constructor for time based LruCache
.
pub fn with_expiry_duration_and_capacity(
time_to_live: Duration,
capacity: usize
) -> LruCache<Key, Value>
[src]
pub fn with_expiry_duration_and_capacity(
time_to_live: Duration,
capacity: usize
) -> LruCache<Key, Value>
[src]Constructor for dual-feature capacity and time based LruCache
.
Inserts a key-value pair into the cache.
If the key already existed in the cache, the existing value is returned and overwritten in
the cache. Otherwise, the key-value pair is inserted and None
is returned.
Evicts and returns expired entries.
Inserts a key-value pair into the cache.
If the key already existed in the cache, the existing value is returned and overwritten in
the cache. Otherwise, the key-value pair is inserted and None
is returned.
Removes a key-value pair from the cache.
Much like get()
, except in addition returns expired entries.
Retrieves a reference to the value stored under key
, or None
if the key doesn’t exist.
Also removes expired elements and updates the time.
Returns a reference to the value with the given key
, if present and not expired, without
updating the timestamp.
Retrieves a mutable reference to the value stored under key
, or None
if the key doesn’t
exist. Also removes expired elements and updates the time.
Retrieves a mutable reference to the value stored under key
, or None
if the key doesn’t
exist. Also removes expired elements and updates the time.
Returns whether key
exists in the cache or not.
Returns the size of the cache, i.e. the number of cached non-expired key-value pairs.
Gets the given key’s corresponding entry in the map for in-place manipulation.
pub fn notify_iter(&mut self) -> NotifyIter<'_, Key, Value>ⓘNotable traits for NotifyIter<'a, Key, Value>
impl<'a, Key, Value> Iterator for NotifyIter<'a, Key, Value> where
Key: Ord + Clone, type Item = TimedEntry<'a, Key, Value>;
[src]
pub fn notify_iter(&mut self) -> NotifyIter<'_, Key, Value>ⓘNotable traits for NotifyIter<'a, Key, Value>
impl<'a, Key, Value> Iterator for NotifyIter<'a, Key, Value> where
Key: Ord + Clone, type Item = TimedEntry<'a, Key, Value>;
[src]Returns an iterator over all entries that updates the timestamps as values are traversed. Also removes expired elements before creating the iterator. Values are produced in the most recently used order.
Also, evicts and returns expired entries.
Returns an iterator over all entries that updates the timestamps as values are traversed. Also removes expired elements before creating the iterator. Values are produced in the most recently used order.
Trait Implementations
Auto Trait Implementations
impl<Key, Value> RefUnwindSafe for LruCache<Key, Value> where
Key: RefUnwindSafe,
Value: RefUnwindSafe,
impl<Key, Value> UnwindSafe for LruCache<Key, Value> where
Key: RefUnwindSafe + UnwindSafe,
Value: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more