pub struct S3Fifo<K, V> { /* private fields */ }Expand description
S3-FIFO cache with scan-resistant eviction.
Implementations§
Source§impl<K, V> S3Fifo<K, V>
impl<K, V> S3Fifo<K, V>
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new S3-FIFO cache with the given total capacity.
The capacity is split: 10% small, 90% main. Ghost capacity matches small capacity. Minimum total capacity is 2.
Sourcepub fn get(&mut self, key: &K) -> Option<&V>
pub fn get(&mut self, key: &K) -> Option<&V>
Look up a value by key, incrementing the frequency counter on hit.
Sourcepub fn insert(&mut self, key: K, value: V) -> Option<V>
pub fn insert(&mut self, key: K, value: V) -> Option<V>
Insert a key-value pair. Returns the evicted value if an existing entry with the same key was replaced.
Sourcepub fn stats(&self) -> S3FifoStats
pub fn stats(&self) -> S3FifoStats
Cache statistics.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Check if the cache contains a key (without incrementing freq).
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for S3Fifo<K, V>
impl<K, V> RefUnwindSafe for S3Fifo<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for S3Fifo<K, V>
impl<K, V> Sync for S3Fifo<K, V>
impl<K, V> Unpin for S3Fifo<K, V>
impl<K, V> UnsafeUnpin for S3Fifo<K, V>
impl<K, V> UnwindSafe for S3Fifo<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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
Mutably borrows from an owned value. Read more