pub struct DedupStore { /* private fields */ }Expand description
In-memory store for deduplicating events within a configurable TTL window.
Thread-safe via DashMap. All methods take &self (no exclusive lock needed).
Implementations§
Source§impl DedupStore
impl DedupStore
Sourcepub fn check_and_insert(
&self,
session_id: &str,
tool_name: &str,
tool_input: &Value,
) -> bool
pub fn check_and_insert( &self, session_id: &str, tool_name: &str, tool_input: &Value, ) -> bool
Check if this event is a duplicate and insert it if it is not.
Returns true if the event was seen within the TTL window (it IS a duplicate).
Returns false if the event is new and inserts it for future dedup checks.
The dedup key is: SHA-like hash of (session_id, tool_name, canonical_json(tool_input)).
Sourcepub fn evict_expired(&self)
pub fn evict_expired(&self)
Evict all entries older than the TTL.
Call periodically to prevent unbounded memory growth in long-running sessions. Under normal load (100ms TTL, <1000 events/session) the map stays very small and eviction is low-priority.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DedupStore
impl !RefUnwindSafe for DedupStore
impl Send for DedupStore
impl Sync for DedupStore
impl Unpin for DedupStore
impl UnsafeUnpin for DedupStore
impl UnwindSafe for DedupStore
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