MessageDeduplicationCache

class MessageDeduplicationCache(cacheSize: Int, logger: Logger, description: String)(source)

Remembers recently seen message IDs so a message relayed back to its origin server is dropped instead of echoed.

Entries expire after CLEANUP_THRESHOLD_MILLIS; if the cache is still over cacheSize after that, the oldest entries go too. Entries are ordered by millisecond timestamp, so a burst of more than cacheSize messages inside one millisecond evicts arbitrarily among them.

Parameters

cacheSize

Soft upper bound on retained entries

logger

Where cleanup failures are reported

description

Names this cache in log output

Constructors

Link copied to clipboard
constructor(cacheSize: Int, logger: Logger, description: String)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun isNew(messageId: String): Boolean

Returns true when messageId has not been seen yet.

Link copied to clipboard
fun markProcessed(messageId: String)

Records messageId as seen, evicting stale entries when the cache outgrows cacheSize.