Struct cached::TimedSizedCache[][src]

pub struct TimedSizedCache<K, V> { /* fields omitted */ }
Expand description

Timed LRU Cache

Stores a limited number of values, evicting expired and least-used entries. Time expiration is determined based on entry insertion time.. The TTL of an entry is not updated when retrieved.

Note: This cache is in-memory only

Implementations

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

Creates a new SizedCache with a given size limit and pre-allocated backing data. Also set if the ttl should be refreshed on retriving

Return an iterator of keys in the current order from most to least recently used. Items passed their expiration seconds will be excluded.

Return an iterator of timestamped values in the current order from most to least recently used. Items passed their expiration seconds will be excluded.

Returns if the lifetime is refreshed when the value is retrived

Sets if the lifetime is refreshed when the value is retrived

Returns a reference to the cache’s store

Trait Implementations

Attempt to retrieve a cached value

Attempt to retrieve a cached value with mutable access

Get or insert a key, value pair

Insert a key, value pair and return the previous value

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

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.