Cache class
A simple in-memory cache with generic support and multiple access patterns.
Example
const cache = new Cache<string, number>();
cache.set("answer", 42);
console.log(cache.get("answer")); // 42Constructors
constructor constructor
Signature
Type Parameters
- K
The type of cache keys
- V
The type of cached values
Methods
cleanup method
Signature
(): number
Clear all expired entries from the cache.
Returns
Number of entries removed
clear method
deprecated
Use cleanup instead Clear the entire cache.
Signature
(): void
get (1/2) method
Signature
(key: K): V
Example
const value = cache.get("myKey");Parameters
- key
The cache key
Returns
The cached value, or undefined if not found or expired