Class: LRUCache<T>
LRU (Least Recently Used) Cache implementation Implements the ICache interface with:
- Configurable capacity limits
- TTL-based expiration
- LRU eviction policy
- Hit rate tracking
Example
T
Type Parameters
T
T
The type of values stored in the cache
Implements
ICache<T>
Constructors
Constructor
ICache
Parameters
config
Returns
LRUCache<T>
Methods
clear()
T
Removes all entries from the cache
Returns
void
Implementation of
delete()
CacheConfig
Removes a specific key from the cache
Parameters
key
string
Returns
boolean
Implementation of
get()
LRUCache
Retrieves a value from the cache Updates access time for LRU tracking Returns undefined if key doesn’t exist or is expired
Parameters
key
string
Returns
undefined | T
Implementation of
getStats()
T
Returns cache statistics
Returns
Implementation of
has()
void
Checks if a key exists and is not expired
Parameters
key
string
Returns
boolean
Implementation of
keys()
ICache
Returns all keys in the cache
Returns
string[]
Implementation of
set()
clear
Stores a value in the cache Evicts LRU item if at capacity Refreshes TTL for existing keys
Parameters
key
string
value
T
Returns
void
Implementation of
Last updated on