Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jzszdznzzl/WABotJS/llms.txt
Use this file to discover all available pages before exploring further.
Utils.TTLCache<V> is a generic in-memory cache where every entry carries an expiry timestamp. An entry is considered expired once Date.now() surpasses insertTime + ttl. Expiry is not checked by get() — it returns the stored value regardless of whether the entry has expired. Expiry is enforced by has() (which returns false for expired entries) and by the bulk-read methods keys(), values(), and entries(), all of which filter out expired entries before returning results. A background setInterval cleaner also runs at the same interval as the TTL to sweep expired entries from the underlying Map, keeping memory usage bounded even when entries are never explicitly read.
Import & construction
Constructor
Time-to-live in milliseconds. Every entry inserted with
set() expires after
this many milliseconds. Must be a positive number — throws TypeError if the
value is not a number or is less than 1.Properties
size
Methods
set(key, value)
Date.now() + ttl). Also starts the background cleaner if it is not already running. Returns this for chaining.
Cache key. Must be a string — throws
TypeError otherwise.Value to store.
get(key)
key regardless of expiry, or undefined if the key does not exist.
Cache key to look up.
del(key)
true if the key existed (regardless of expiry), false if it was not found.
Cache key to delete.
has(key)
true only if the key exists and its expiry timestamp has not yet passed. Expired entries return false even if the cleaner has not yet removed them from the underlying Map.
clear()
set() is called.
keys()
values()
keys().
entries()
[key, value] tuples for all non-expired entries.
Background cleaner
The TTLCache starts asetInterval cleaner the first time set() is called. The interval period equals the TTL. On each tick, every entry whose expiry timestamp has passed is removed from the underlying Map. When the Map is fully empty, the cleaner stops itself automatically.
The cleaner interval is unref’d via
interval.unref(). This means the
interval will not keep the Node.js event loop alive on its own — your process
can exit normally even if the cache still holds entries with a pending cleaner.