#[non_exhaustive]pub enum EvictionStrategy {
Fifo,
Lru(LruStrategy),
}Expand description
Eviction strategy for the cache.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Fifo
First-In-First-Out: evicts the oldest entries first (by insertion time).
Lru(LruStrategy)
Sharded, approximate Least Recently Used eviction. See LruStrategy.
This is not a globally-exact LRU. To reduce serialization overhead on
large caches, the entries are split across independent shards (see
LruStrategy::shards) and eviction happens per shard: when a shard is
full, that shard evicts its own least recently accessed entry. With keys
spread across shards, the globally least recently used entry is only
evicted approximately, since eviction only ever considers one shard’s
entries at a time. Both get() and save() update the access time.
With a single shard (LruStrategy::shards(1)) the whole cache lives in
one queue, so eviction is exact, global LRU at the cost of no sharding.
Trait Implementations§
Source§impl Clone for EvictionStrategy
impl Clone for EvictionStrategy
impl Copy for EvictionStrategy
Source§impl Debug for EvictionStrategy
impl Debug for EvictionStrategy
impl Eq for EvictionStrategy
Source§impl PartialEq for EvictionStrategy
impl PartialEq for EvictionStrategy
impl StructuralPartialEq for EvictionStrategy
Auto Trait Implementations§
impl Freeze for EvictionStrategy
impl RefUnwindSafe for EvictionStrategy
impl Send for EvictionStrategy
impl Sync for EvictionStrategy
impl Unpin for EvictionStrategy
impl UnsafeUnpin for EvictionStrategy
impl UnwindSafe for EvictionStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.