pub struct DuplicateCache<const N: usize = 64> { /* private fields */ }Expand description
Fixed-capacity cache of recently observed duplicate keys.
Entries leave either by age (DUP_CACHE_TTL_MS) or by eviction of the
oldest when the ring is full, whichever comes first.
Implementations§
Source§impl<const N: usize> DuplicateCache<N>
impl<const N: usize> DuplicateCache<N>
Sourcepub fn contains(&self, key: &DupCacheKey, now_ms: u64) -> bool
pub fn contains(&self, key: &DupCacheKey, now_ms: u64) -> bool
Return whether key is present and has not aged out.
Sourcepub fn insert(&mut self, key: DupCacheKey, now_ms: u64)
pub fn insert(&mut self, key: DupCacheKey, now_ms: u64)
Insert key, dropping aged-out entries and evicting the oldest
survivor if the ring is still full.
A repeat of a key already held does not refresh its timestamp: the entry ages from when the packet was first seen, so a node repeating itself inside the window cannot hold its own suppression open.
Sourcepub fn expire(&mut self, now_ms: u64)
pub fn expire(&mut self, now_ms: u64)
Drop every entry older than DUP_CACHE_TTL_MS.
Trait Implementations§
Source§impl<const N: usize> Clone for DuplicateCache<N>
impl<const N: usize> Clone for DuplicateCache<N>
Source§fn clone(&self) -> DuplicateCache<N>
fn clone(&self) -> DuplicateCache<N>
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<const N: usize> Debug for DuplicateCache<N>
impl<const N: usize> Debug for DuplicateCache<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for DuplicateCache<N>
impl<const N: usize> RefUnwindSafe for DuplicateCache<N>
impl<const N: usize> Send for DuplicateCache<N>
impl<const N: usize> Sync for DuplicateCache<N>
impl<const N: usize> Unpin for DuplicateCache<N>
impl<const N: usize> UnwindSafe for DuplicateCache<N>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)