The type of keys stored in the cache
The type of values stored in the cache
Creates a new instance of CacheLRUWithTTL
Configuration options for the cache
Maximum number of items the cache can hold. Must be a non-negative integer
Time to live in milliseconds for cache items. Must be a non-negative integer
If true, keeps the cleanup timer running even when process.exit is called
Interval in milliseconds between cleanup runs. Must be at least 1000ms
Gets the number of key-value pairs in the cache.
The total number of entries in the cache.
Stops the cleanup timer for expired cache entries if one is running. This should be called when shutting down the cache to prevent memory leaks.
Removes all entries from the cache. After calling this method, the cache will be empty.
Removes the specified key from the cache.
The key to remove from the cache
Returns true if an element in the cache existed and has been removed, or false if the element does not exist
Checks if a key exists in the cache and is not expired
The key to check in the cache
True if the key exists and has not expired, false otherwise
Sets a key-value pair in the cache with an optional time-to-live (TTL).
void
A Least Recently Used (LRU) cache implementation with Time-To-Live (TTL) support.
Example
Remarks
Throws
When constructor options have invalid types or values: