pub struct LRUCache<K, V> where
    K: Eq + Hash
{ blocks: LinkedList<Block<K, V>>, block_refs: HashMap<K, Link>, }
Expand description

A Least-Recently-Used (LRU) Cache implemented using a generational arena based linked list and a hash map.

Fields

blocks: LinkedList<Block<K, V>>block_refs: HashMap<K, Link>

Implementations

Creates an LRUCache instance with the given capacity. A zero capacity LRUCache is unusable.

Returns a reference to the value associated with the given key. If the key is not present in the cache, we return a “cache-miss” error. If the entry is found but cannot be fetched from the underlying storage, we return a “cache-broken” error.

Removes the associated key value pair for the given key from this cache. If no entry is found, we return a “cache-miss” error. If the entry is found but cannot be fetched from the underlying in-memory storage, we return a “cache-broken” error. Returns the value associated, after removal with ownership.

Inserts a new key value pair into this cache. If this cache is full, the least recently used entry is removed.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.