pub struct TtlMap<K: Hash + Eq + Clone, V> { /* private fields */ }Expand description
A HashMap which enforces a time-to-live of records inserted into it.
This is purely a data structure and does not do its own timekeeping; times are instead passed in as an argument to each method.
Compaction happens automatically when values are read or written. As a consequence of this, even reads require the data structure to be mutable.
Implementations§
Source§impl<K: Hash + Eq + Clone, V> TtlMap<K, V>
impl<K: Hash + Eq + Clone, V> TtlMap<K, V>
pub fn new(ttl: Duration) -> Self
pub fn insert(&mut self, key: K, value: V, time: SystemTime)
pub fn get_or_insert_with<F: FnOnce() -> V>( &mut self, key: K, func: F, ) -> &mut V
pub fn get(&mut self, key: &K, time: SystemTime) -> Option<&V>
pub fn get_mut(&mut self, key: &K, time: SystemTime) -> Option<&mut V>
Auto Trait Implementations§
impl<K, V> Freeze for TtlMap<K, V>
impl<K, V> RefUnwindSafe for TtlMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for TtlMap<K, V>
impl<K, V> Sync for TtlMap<K, V>
impl<K, V> Unpin for TtlMap<K, V>
impl<K, V> UnwindSafe for TtlMap<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