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.

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.

Clears the LruCache, removing all values.

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.

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. 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.

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.