logo
pub struct Cache<T, V> where
    T: Hash + Eq + Copy
{ /* private fields */ }
Expand description

A BTreeMap-backed cache supporting capacity- and duration-based expiry.

Implementations

Creating capacity based Cache.

Creating time based Cache.

Creating dual-feature capacity and time based Cache.

Returns the number of items in the cache.

Returns true if the cache contains no items.

Returns the number of items in the cache that match the given predicate.

Get a value from the cache if one is set and not expired.

A clone of the value is returned, so this is only implemented when V: Clone.

Set a value in the cache and return the previous value, if any.

This will override an existing value for the same key, if there is one. custom_duration can be set to override self.item_duration. If the new item causes the cache to exceed its capacity, the oldest entry in the cache will be removed.

Remove expired items from the cache storage.

Remove an item from the cache, returning the removed value.

Clear the cache, removing all items.

Trait Implementations

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.

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

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

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