Struct cached::SizedCache

source ·
pub struct SizedCache<K, V> { /* private fields */ }
Expand description

Least Recently Used / Sized Cache

Stores up to a specified size before beginning to evict the least recently used keys

Note: This cache is in-memory only

Implementations§

👎Deprecated since 0.5.1: method renamed to with_size

Creates a new SizedCache with a given size limit and pre-allocated backing data

Panics

Will panic if size is 0

Creates a new SizedCache with a given size limit and pre-allocated backing data

Errors

Will return a std::io::Error, depending on the error

Return an iterator of keys in the current order from most to least recently used.

Return an iterator of values in the current order from most to least recently used.

Returns a reference to the cache’s order

Trait Implementations§

Attempt to retrieve a cached value
Attempt to retrieve a cached value with mutable access
Insert a key, value pair and return the previous value
Get or insert a key, value pair
Remove a cached value
Remove all cached values. Keeps the allocated memory for reuse.
Remove all cached values. Free memory and return to initial state
Reset misses/hits counters
Return the current cache size (number of elements)
Return the number of times a cached value was successfully retrieved
Return the number of times a cached value was unable to be retrieved
Return the cache capacity
Return the lifespan of cached values (time to eviction)
Set the lifespan of cached values, returns the old value
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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
Checks if this value is equivalent to the given key. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more