#[non_exhaustive]pub enum EvictionPolicy {
Lru,
Lfu,
Fifo,
Arc,
}Expand description
Which entry an eviction discards when the cache is full.
All four policies keep the cache within its capacity; they differ only in
which entry they sacrifice to make room. The default is Lru,
the best general-purpose choice for search workloads.
§Examples
use iqdb_cache::EvictionPolicy;
assert_eq!(EvictionPolicy::default(), EvictionPolicy::Lru);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Lru
Least Recently Used. Discards the entry untouched for the longest. The default: it adapts to shifting query hot-sets and is the strongest general default for search.
Lfu
Least Frequently Used. Discards the entry with the fewest lifetime hits, breaking ties by least-recently-used. Favors stable, skewed workloads where a few queries dominate.
Fifo
First In, First Out. Discards the oldest inserted entry regardless of access. The cheapest policy; a good fit when reuse is uniform.
Arc
Adaptive Replacement Cache. Balances recency and frequency automatically using ghost lists, tuning itself between LRU- and LFU-like behavior as the workload shifts.
Trait Implementations§
Source§impl Clone for EvictionPolicy
impl Clone for EvictionPolicy
Source§fn clone(&self) -> EvictionPolicy
fn clone(&self) -> EvictionPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for EvictionPolicy
Source§impl Debug for EvictionPolicy
impl Debug for EvictionPolicy
Source§impl Default for EvictionPolicy
impl Default for EvictionPolicy
Source§fn default() -> EvictionPolicy
fn default() -> EvictionPolicy
Source§impl<'de> Deserialize<'de> for EvictionPolicy
Available on crate feature serde only.
impl<'de> Deserialize<'de> for EvictionPolicy
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for EvictionPolicy
Source§impl Hash for EvictionPolicy
impl Hash for EvictionPolicy
Source§impl PartialEq for EvictionPolicy
impl PartialEq for EvictionPolicy
Source§impl Serialize for EvictionPolicy
Available on crate feature serde only.
impl Serialize for EvictionPolicy
serde only.