pub struct SieveCache<V> { /* private fields */ }Expand description
SIEVE eviction cache.
Single FIFO queue with a moving eviction hand and a visited bit. Dirty entries are pinned and never evictable.
O(1) amortized eviction.
Implementations§
Source§impl<V: Default> SieveCache<V>
impl<V: Default> SieveCache<V>
pub fn new(capacity: usize) -> Self
pub fn get(&mut self, key: u64) -> Option<&V>
pub fn get_mut(&mut self, key: u64) -> Option<&mut V>
pub fn contains(&self, key: u64) -> bool
Sourcepub fn insert(&mut self, key: u64, value: V) -> Result<Option<(u64, V)>, ()>
pub fn insert(&mut self, key: u64, value: V) -> Result<Option<(u64, V)>, ()>
Returns Err if all entries are dirty (pinned) and eviction is impossible.
pub fn set_dirty(&mut self, key: u64)
pub fn clear_dirty(&mut self, key: u64)
pub fn is_dirty(&self, key: u64) -> bool
pub fn dirty_entries(&self) -> impl Iterator<Item = (u64, &V)>
pub fn dirty_entries_mut(&mut self) -> impl Iterator<Item = (u64, &mut V)>
pub fn clear_all_dirty(&mut self)
pub fn remove(&mut self, key: u64) -> Option<V>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
pub fn dirty_count(&self) -> usize
pub fn clear(&mut self)
Auto Trait Implementations§
impl<V> Freeze for SieveCache<V>
impl<V> RefUnwindSafe for SieveCache<V>where
V: RefUnwindSafe,
impl<V> Send for SieveCache<V>where
V: Send,
impl<V> Sync for SieveCache<V>where
V: Sync,
impl<V> Unpin for SieveCache<V>where
V: Unpin,
impl<V> UnsafeUnpin for SieveCache<V>
impl<V> UnwindSafe for SieveCache<V>where
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