pub struct TtlCache<K, T>{ /* private fields */ }
Expand description
A time-to-live cache that removes values when they expire. This is used to store and look up orders, to determine how old they are for rate limiting penalties when editing or cancelling.
Implementations§
Source§impl<K, T> TtlCache<K, T>
impl<K, T> TtlCache<K, T>
Sourcepub fn insert(&mut self, ttl_entry: TtlEntry<K, T>) -> Option<TtlEntry<K, T>>
pub fn insert(&mut self, ttl_entry: TtlEntry<K, T>) -> Option<TtlEntry<K, T>>
Insert the provided TtlEntry by it’s id for future lookup. Entries beyond their ttl are
removed automatically any time the remove
, get
, or contains
methods are called.
Sourcepub fn remove(&mut self, ttl_entry: &TtlEntry<K, T>) -> bool
pub fn remove(&mut self, ttl_entry: &TtlEntry<K, T>) -> bool
Removes an entry manually, returning if the entry was removed.
The cache is cleaned of any expired values after checking if this value was removed.
This follows the same semantics as BTreeSet’s remove
method.
Trait Implementations§
Auto Trait Implementations§
impl<K, T> Freeze for TtlCache<K, T>
impl<K, T> RefUnwindSafe for TtlCache<K, T>where
K: RefUnwindSafe,
T: RefUnwindSafe,
impl<K, T> Send for TtlCache<K, T>
impl<K, T> Sync for TtlCache<K, T>
impl<K, T> Unpin for TtlCache<K, T>
impl<K, T> UnwindSafe for TtlCache<K, T>where
K: RefUnwindSafe,
T: RefUnwindSafe,
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