pub struct LruCache<K, V, S = DefaultHashBuilder> { /* private fields */ }

Implementations

Create a new unbounded LruCache that does not automatically evict entries.

A simple convenience method that is equivalent to LruCache::new(usize::MAX)

Insert a new value into the LruCache.

If necessary, will remove the value at the front of the LRU list to make room.

Get the value for the given key, without marking the value as recently used and moving it to the back of the LRU list.

Get the value for the given key mutably, without marking the value as recently used and moving it to the back of the LRU list.

Retrieve the given key, marking it as recently used and moving it to the back of the LRU list.

Retrieve the given key, marking it as recently used and moving it to the back of the LRU list.

If the returned entry is vacant, it will always have room to insert a single value. By using the entry API, you can exceed the configured capacity by 1.

The returned entry is not automatically moved to the back of the LRU list. By calling Entry::to_back / Entry::to_front you can manually control the position of this entry in the LRU list.

source

pub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>

The constructed raw entry is never automatically moved to the back of the LRU list. By calling Entry::to_back / Entry::to_front you can manually control the position of this entry in the LRU list.

source

pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>

If the constructed raw entry is vacant, it will always have room to insert a single value. By using the raw entry API, you can exceed the configured capacity by 1.

The constructed raw entry is never automatically moved to the back of the LRU list. By calling Entry::to_back / Entry::to_front you can manually control the position of this entry in the LRU list.

source

pub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized,

Set the new cache capacity for the LruCache.

If there are more entries in the LruCache than the new capacity will allow, they are removed.

Remove the least recently used entry and return it.

If the LruCache is empty this will return None.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. 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

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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.