pub struct DefaultLifecycle<Key, Val>(/* private fields */);Expand description
Default Lifecycle for a sync cache.
Stashes up to two evicted items for dropping them outside the cache locks.
Trait Implementations§
Source§impl<Key, Val> Clone for DefaultLifecycle<Key, Val>
impl<Key, Val> Clone for DefaultLifecycle<Key, Val>
Source§impl<Key, Val> Debug for DefaultLifecycle<Key, Val>
impl<Key, Val> Debug for DefaultLifecycle<Key, Val>
Source§impl<Key, Val> Default for DefaultLifecycle<Key, Val>
impl<Key, Val> Default for DefaultLifecycle<Key, Val>
Source§impl<Key, Val> Lifecycle<Key, Val> for DefaultLifecycle<Key, Val>
impl<Key, Val> Lifecycle<Key, Val> for DefaultLifecycle<Key, Val>
Source§type RequestState = [Option<(Key, Val)>; 2]
type RequestState = [Option<(Key, Val)>; 2]
Per-request accumulator threaded through the eviction hooks. Read more
Source§fn on_evict(&self, state: &mut Self::RequestState, key: Key, val: Val)
fn on_evict(&self, state: &mut Self::RequestState, key: Key, val: Val)
Called when an item is evicted. Read more
Source§fn is_pinned(&self, key: &Key, val: &Val) -> bool
fn is_pinned(&self, key: &Key, val: &Val) -> bool
Returns whether the item is pinned. Items that are pinned can’t be evicted.
Note that a pinned item can still be replaced with get_mut, insert, replace and similar APIs. Read more
Source§fn before_evict(&self, state: &mut Self::RequestState, key: &Key, val: &mut Val)
fn before_evict(&self, state: &mut Self::RequestState, key: &Key, val: &mut Val)
Called when a cache item is about to be evicted.
Note that value replacement (e.g. insertions for the same key) won’t call this method. Read more
Source§fn on_evict_cold(&self, state: &mut Self::RequestState, key: Key, val: Val)
fn on_evict_cold(&self, state: &mut Self::RequestState, key: Key, val: Val)
Called when an item is evicted from the cold queue. Read more
Source§fn on_evict_hot(&self, state: &mut Self::RequestState, key: Key, val: Val)
fn on_evict_hot(&self, state: &mut Self::RequestState, key: Key, val: Val)
Called when an item is evicted from the hot queue. Read more
Auto Trait Implementations§
impl<Key, Val> Freeze for DefaultLifecycle<Key, Val>
impl<Key, Val> RefUnwindSafe for DefaultLifecycle<Key, Val>where
Key: RefUnwindSafe,
Val: RefUnwindSafe,
impl<Key, Val> Send for DefaultLifecycle<Key, Val>
impl<Key, Val> Sync for DefaultLifecycle<Key, Val>
impl<Key, Val> Unpin for DefaultLifecycle<Key, Val>
impl<Key, Val> UnsafeUnpin for DefaultLifecycle<Key, Val>
impl<Key, Val> UnwindSafe for DefaultLifecycle<Key, Val>where
Key: UnwindSafe,
Val: 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