Struct dynamic_lru_cache::DynamicCache [−][src]
pub struct DynamicCache<K, V, S = RandomState> { /* fields omitted */ }Expand description
A cache that will only hold onto items that have been reqeuested more than once in recent memory. Single-use items are not held at all. Once an item is requested twice, it is cached until all memory of seeing it requested has expired. The length of the memory is adjustable, and must be set at initialization.
This version of the cache can be shared across threads without issue, as it is an instance of
DynamicCacheLocal held by an Arc<Mutex<T>>.
Implementations
Create and initialize a new cache, using the given hash builder to hash keys. The same
warnings given for HashMap::with_hasher apply here.
Fetch an item via the cache, potentially filling in the cache on a miss via the function
f. The cache is unlocked while calling the function, so f may be called more than once
with the same parameters if there are several threads using the cache.
Change the length of the cache’s recent request memory. Some contents of the cache may be removed immediately if the new memory length is shorter than the old memory length.
Clear out all stored values and all memory in the cache.
Reset the cache hit/miss metrics.
Trait Implementations
Auto Trait Implementations
impl<K, V, S = RandomState> !RefUnwindSafe for DynamicCache<K, V, S>
impl<K, V, S> Unpin for DynamicCache<K, V, S>
impl<K, V, S = RandomState> !UnwindSafe for DynamicCache<K, V, S>
Blanket Implementations
Mutably borrows from an owned value. Read more