pub struct TtlCache<K, V> { /* private fields */ }Expand description
A concurrent cache with per-entry TTL eviction.
Entries are automatically considered expired after their TTL elapses. Expired entries are lazily evicted on access.
Implementations§
Source§impl<K: Eq + Hash + Clone, V: Clone> TtlCache<K, V>
impl<K: Eq + Hash + Clone, V: Clone> TtlCache<K, V>
Sourcepub fn take_fresh(&self, key: &K) -> Option<V>
pub fn take_fresh(&self, key: &K) -> Option<V>
Remove an entry only if it has not expired, returning its value.
Unlike TtlCache::remove (which returns the value even when
expired), this is the single-use-consume primitive: an expired entry
is dropped and reported as absent — exactly the semantics a CSRF
state store or one-time token cache needs.
Trait Implementations§
Auto Trait Implementations§
impl<K, V> !RefUnwindSafe for TtlCache<K, V>
impl<K, V> Freeze for TtlCache<K, V>
impl<K, V> Send for TtlCache<K, V>
impl<K, V> Sync for TtlCache<K, V>
impl<K, V> Unpin for TtlCache<K, V>
impl<K, V> UnsafeUnpin for TtlCache<K, V>where
DashMap<K, CacheEntry<V>>: UnsafeUnpin,
impl<K, V> UnwindSafe for TtlCache<K, V>where
DashMap<K, CacheEntry<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