Struct safe_network::routing::Cache [−][src]
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 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.
Trait Implementations
Auto Trait Implementations
impl<T, V> !RefUnwindSafe for Cache<T, V>
impl<T, V> UnwindSafe for Cache<T, V> where
T: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self