Class

LimitedCollection

Collection with optional FIFO eviction when a new key is inserted at capacity. Construction is Map-safe: options are never passed to super(), so subclasses can call super({ maxSize, onEvict }) without Map treating the options object as an iterable.

Extends Collection

Constructor

new LimitedCollection(options: LimitedCollectionOptions<K, V>)

Properties

NameTypeDescription
boundedread-onlybooleanWhether this collection enforces a finite capacity.
maxSizeread-onlynumber
onEvictread-only((key: K, value: V) => void) | null

Methods

.clone()

LimitedCollection<K, V>

Clone into a new LimitedCollection with the same limits (no onEvict callback).

client.users.clone();

.set(key, value)

key: K, value: Vthis

Insert or update an entry. When at capacity and key is new, the oldest entry is removed (FIFO by Map insertion order) and onEvict is invoked if set.

client.users.set(key, value);

.sweep(filter?)

filter?: (value: V, key: K) => booleannumber

Remove entries matching filter (or all if omitted). Returns count removed. Does not invoke onEvict — callers that need cascade teardown should handle it.

client.users.sweep();