pub struct ExpiringValueCache<K: Hash + Eq, V: CanExpire> { /* private fields */ }
Expand description

Expiring Value Cache

Stores values that implement the CanExpire trait so that expiration is determined by the values themselves. This is useful for caching values which themselves contain an expiry timestamp.

Note: This cache is in-memory only.

Implementations

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

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

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

Reset misses/hits counters

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

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