Class

MessageCache

Per-channel message cache with FIFO eviction. - `false` limit → caching disabled - `Infinity` / unbounded → no per-channel cap - positive → max messages per channel Outer map of channel caches is itself FIFO-bounded by `getChannelLimit`. get never creates empty maps (use add).

Constructor

new MessageCache(getLimit: () => MessageLimit, getChannelLimit: () => number)
ParamTypeDescription
getLimit() => MessageLimit
getChannelLimit() => number

Properties

caches: Map<string, Map<string, APIMessage>> | null

Methods

add(channelId: string, data: APIMessage): void
ParamTypeDescription
channelIdstring
dataAPIMessage
clearChannel(channelId: string): void
ParamTypeDescription
channelIdstring
get(channelId: string): Map<string, APIMessage> | null

Return the existing per-channel map, or `null` if disabled / not yet created. Does **not** create empty maps.

ParamTypeDescription
channelIdstring
remove(channelId: string, messageId: string): void
ParamTypeDescription
channelIdstring
messageIdstring
reset(): void
sweep(filter?: (message: APIMessage, channelId: string) => boolean, channelId?: string): number
ParamTypeDescription
filter?(message: APIMessage, channelId: string) => boolean
channelId?string