Struct lru_time_cache::LruCache [] [src]

pub struct LruCache<Key, Value> { /* fields omitted */ }

Implementation of LRU cache.

Methods

impl<Key, Value> LruCache<Key, Value> where
    Key: Ord + Clone
[src]

Constructor for capacity based LruCache.

Constructor for time based LruCache.

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.

Removes a key-value pair from the cache.

Clears the LruCache, removing all values.

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.

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.

Returns true if there are no non-expired entries in the cache.

Gets the given key's corresponding entry in the map for in-place manipulation.

Returns an iterator over all entries that updates the timestamps as values are traversed. Also removes expired elements before creating the iterator.

Returns an iterator over all entries that does not modify the timestamps.

Trait Implementations

impl<Key, Value> Clone for LruCache<Key, Value> where
    Key: Clone,
    Value: Clone
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more