- LRUCache<T>(options?): {
delete: ((key: unknown) => void);
get: ((key: unknown) => undefined | T);
has: ((key: unknown) => boolean);
refresh: (() => void);
set: ((key: unknown, value: T, ttlOverride?: number) => void);
} Parameters
- options: CacheOptions<T> = {}
Returns {
delete: ((key: unknown) => void);
get: ((key: unknown) => undefined | T);
has: ((key: unknown) => boolean);
refresh: (() => void);
set: ((key: unknown, value: T, ttlOverride?: number) => void);
}
The cache object.
delete: ((key: unknown) => void)
get: ((key: unknown) => undefined | T)
- (key): undefined | T
Returns undefined | T
has: ((key: unknown) => boolean)
- (key): boolean
Returns boolean
refresh: (() => void)
set: ((key: unknown, value: T, ttlOverride?: number) => void)
- (key, value, ttlOverride?): void
Parameters
- key: unknown
- value: T
Optional
ttlOverride: number
Returns void
Creates a Least Recently Used (LRU) cache.
The returned object has the following methods:
delete
: Deletes an item from the cache.get
: Returns the value of an item in the cache.has
: Returns whether an item is in the cache.set
: Sets an item in the cache.refresh
: Deletes all items from the cache.Example