pub struct NegativeCache { /* private fields */ }Expand description
A TTL-keyed negative result cache.
Implementations§
Source§impl NegativeCache
impl NegativeCache
Sourcepub fn insert_miss(&mut self, key: &str, now_ms: u64)
pub fn insert_miss(&mut self, key: &str, now_ms: u64)
Record key as a known miss at timestamp now_ms.
If an entry for key already exists it is overwritten with the new
timestamp (refreshing the TTL).
Sourcepub fn is_known_miss(&self, key: &str, now_ms: u64) -> bool
pub fn is_known_miss(&self, key: &str, now_ms: u64) -> bool
Returns true when key is a known miss that has not yet expired.
A miss entry at recorded_ms expires when now_ms >= recorded_ms + ttl_ms.
Sourcepub fn remove(&mut self, key: &str)
pub fn remove(&mut self, key: &str)
Remove the entry for key (e.g. after it has been successfully
populated in the origin cache).
Sourcepub fn evict_expired(&mut self, now_ms: u64)
pub fn evict_expired(&mut self, now_ms: u64)
Prune all entries that have expired by now_ms.
Trait Implementations§
Source§impl Clone for NegativeCache
impl Clone for NegativeCache
Source§fn clone(&self) -> NegativeCache
fn clone(&self) -> NegativeCache
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NegativeCache
impl RefUnwindSafe for NegativeCache
impl Send for NegativeCache
impl Sync for NegativeCache
impl Unpin for NegativeCache
impl UnsafeUnpin for NegativeCache
impl UnwindSafe for NegativeCache
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