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.LRUCache<V> is a generic, capacity-bounded in-memory cache that implements a Least-Recently-Used eviction policy. When the cache is full and a new entry is inserted, the entry that was accessed least recently is automatically removed to make room. The implementation is backed by an insertion-ordered Map and moves entries to the tail on every read, so eviction candidates are always at the head.
Import & construction
Constructor
Maximum number of entries the cache may hold at any time. Must be a positive
integer. Throws
TypeError if the value is not a number or is less than 1.Properties
size
Map size — the total number of entries currently held in the cache, including any that may be pending eviction. No filtering is applied; every key tracked by the underlying Map is counted.
Methods
set(key, value)
this for chaining.
Cache key. Must be a string — throws
TypeError otherwise.Value to store.
get(key)
key, or undefined if the key is not present. Accessing an entry via get moves it to the most-recently-used position, refreshing it against eviction.
Cache key to look up.
del(key)
true if the key existed and was deleted, false if it was not found.
Cache key to delete.
has(key)
true if the key exists in the cache, false otherwise. Does not affect recency order.
clear()
keys()
values()
entries()
[key, value] tuples in LRU-to-MRU order.
Eviction policy
The LRU eviction policy guarantees that the entry removed on overflow is
always the one that was least recently accessed — not the one that was
inserted longest ago. Calling
get() on an entry refreshes its recency
position; calling set() on an existing key also moves it to the
most-recently-used position before updating its value.