Interface IInMemoryDeduplicator
Interface for lightweight in-memory message deduplication without full inbox persistence.
public interface IInMemoryDeduplicator
- Extension Methods
Remarks
This provides a simpler alternative to full inbox persistence for scenarios where:
- Message volume is moderate
- Duplicate detection window is short (hours, not days)
- Message loss on restart is acceptable
- Performance is prioritized over durability
Methods
CleanupExpiredEntriesAsync(CancellationToken)
Removes expired entries from the deduplicator.
Task<int> CleanupExpiredEntriesAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
ClearAsync(CancellationToken)
Clears all tracked message IDs from memory.
Task ClearAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
GetStatistics()
Gets current statistics about deduplicator performance and usage.
DeduplicationStatistics GetStatistics()
Returns
- DeduplicationStatistics
Statistics about the deduplicator.
IsDuplicateAsync(string, TimeSpan, CancellationToken)
Checks if a message ID has already been processed within the expiry window.
Task<bool> IsDuplicateAsync(string messageId, TimeSpan expiry, CancellationToken cancellationToken)
Parameters
messageIdstringThe unique identifier of the message.
expiryTimeSpanHow long to remember the message ID.
cancellationTokenCancellationTokenCancellation token.
Returns
MarkProcessedAsync(string, TimeSpan, CancellationToken)
Marks a message as processed to prevent duplicate processing.
Task MarkProcessedAsync(string messageId, TimeSpan expiry, CancellationToken cancellationToken)
Parameters
messageIdstringThe unique identifier of the message.
expiryTimeSpanHow long to remember the message ID.
cancellationTokenCancellationTokenCancellation token.