pub struct DedupCache { /* private fields */ }Expand description
Message deduplication cache
Implementations§
Source§impl DedupCache
impl DedupCache
Sourcepub fn new(max_size: usize, ttl: Duration) -> Self
pub fn new(max_size: usize, ttl: Duration) -> Self
Create a new deduplication cache
§Arguments
max_size- Maximum number of entries to cachettl- Time-to-live for each entry
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a cache with default settings (10000 entries, 1 hour TTL)
Sourcepub fn insert(&mut self, key: DedupKey) -> bool
pub fn insert(&mut self, key: DedupKey) -> bool
Insert a key into the cache
Returns true if the key was newly inserted, false if it already existed
Sourcepub fn is_duplicate(
&mut self,
message: &Message,
use_content_hash: bool,
) -> bool
pub fn is_duplicate( &mut self, message: &Message, use_content_hash: bool, ) -> bool
Check if a message is a duplicate
Returns true if the message has been seen before, false otherwise
Trait Implementations§
Source§impl Clone for DedupCache
impl Clone for DedupCache
Source§fn clone(&self) -> DedupCache
fn clone(&self) -> DedupCache
Returns a duplicate of the value. Read more
1.0.0 · 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 DedupCache
impl RefUnwindSafe for DedupCache
impl Send for DedupCache
impl Sync for DedupCache
impl Unpin for DedupCache
impl UnwindSafe for DedupCache
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