Class QuickLRU<KeyType, ValueType>
Type Parameters
Index
Constructors
Accessors
Methods
Properties
Accessors
maxSize
- get maxSize(): number
The set max size.
Returns number
size
- get size(): number
The stored item count.
Returns number
Methods
[iterator]
- "[iterator]"(): IterableIterator<[KeyType, ValueType]>
Returns IterableIterator<[KeyType, ValueType]>
clear
delete
entries
- entries(): MapIterator<[KeyType, ValueType]>
Returns an iterable of key, value pairs for every entry in the map.
Returns MapIterator<[KeyType, ValueType]>
entriesAscending
- entriesAscending(): IterableIterator<[KeyType, ValueType]>
Iterable for all entries, starting with the oldest (ascending in recency).
Returns IterableIterator<[KeyType, ValueType]>
entriesDescending
- entriesDescending(): IterableIterator<[KeyType, ValueType]>
Iterable for all entries, starting with the newest (descending in recency).
Returns IterableIterator<[KeyType, ValueType]>
expiresIn
- expiresIn(key: KeyType): number
Get the remaining time to live (in milliseconds) for the given item, or
undefined
when the item is not in the cache.- Does not mark the item as recently used.
- Does not trigger lazy expiration or remove the entry when it is expired.
- Returns
Infinity
if the item has no expiration. - May return a negative number if the item is already expired but not yet lazily removed.
Parameters
- key: KeyType
Returns number
Remaining time to live in milliseconds when set,
Infinity
when there is no expiration, orundefined
when the item does not exist.
forEach
get
has
keys
- keys(): IterableIterator<KeyType>
Iterable for all the keys.
Returns IterableIterator<KeyType>
peek
resize
set
- set(key: KeyType, value: ValueType, options?: { maxAge?: number }): this
Set an item. Returns the instance.
Individual expiration of an item can be specified with the
maxAge
option. If not specified, the globalmaxAge
value will be used in case it is specified in the constructor; otherwise the item will never expire.Returns this
The cache instance.
values
- values(): IterableIterator<ValueType>
Iterable for all the values.
Returns IterableIterator<ValueType>
Simple "Least Recently Used" (LRU) cache.
The instance is an
Iterable
of[key, value]
pairs so you can use it directly in aforβ¦of
loop.