Configured maximum entry count. Read-only after construction.
Current entry count (including any expired entries that haven't been
lazily evicted yet — call Prune() to force eviction first).
Remove every entry, firing onEvict for each with reason 'clear'.
Remove a key. Returns true if removed. Fires onEvict with reason
'delete'.
Eagerly evict all expired entries. Useful from a periodic timer when
lazy eviction (only on Get/Has) isn't sufficient — for example, when
entries hold expensive resources you want released even if no one reads
them again.
Bounded LRU cache with optional TTL — designed to replace the unbounded
Mapfields that proliferate across MJ singletons (per-credential SDK client caches, issuer caches, script caches, etc.). Built onMap's preserved insertion order: touching an entry deletes-and-reinserts to move it to the end, so eviction is trivially the first key.Getreturnsundefinedfor missing or expired entries and lazily evicts expired ones (firingonEvictonce).Setupdates an existing entry in place (resetting recency + TTL) or evicts the least-recently-used whensize === maxSize.onEvictis called for every removal — overflow, expiry, explicit delete, orClear()— so callers can release SDK clients, sockets, etc.Thread-safety: same single-threaded JS guarantees as
Map. Not safe across worker threads — pin one cache per worker.NOTE: this is intentionally minimal. We don't expose
keys()/values()iterators because LRU semantics interact poorly with iteration order — callers who need those should useMapdirectly.