Class QuickLRU<KeyType, ValueType>
Type Parameters
- KeyType
- ValueType
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]
Returns IterableIterator<[KeyType, ValueType]>
clear
Delete all items.
Returns void
delete
Delete an item.
Parameters
- key: KeyType
Returns boolean
trueif the item is removed orfalseif the item doesn't exist.
entries
Returns an iterable of key, value pairs for every entry in the map.
Returns MapIterator<[KeyType, ValueType]>
entriesAscending
Iterable for all entries, starting with the oldest (ascending in recency).
Returns IterableIterator<[KeyType, ValueType]>
entriesDescending
Iterable for all entries, starting with the newest (descending in recency).
Returns IterableIterator<[KeyType, ValueType]>
expiresIn
Get the remaining time to live (in milliseconds) for the given item, or
undefinedwhen 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
Infinityif 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,
Infinitywhen there is no expiration, orundefinedwhen the item does not exist.
forEach
get
has
keys
Iterable for all the keys.
Returns IterableIterator<KeyType>
peek
resize
Update the
maxSizein-place, discarding items as necessary. Insertion order is mostly preserved, though this is not a strong guarantee.Useful for on-the-fly tuning of cache sizes in live systems.
Parameters
- maxSize: number
Returns void
set
Set an item. Returns the instance.
Individual expiration of an item can be specified with the
maxAgeoption. If not specified, the globalmaxAgevalue will be used in case it is specified in the constructor; otherwise the item will never expire.Returns this
The cache instance.
values
Iterable for all the values.
Returns IterableIterator<ValueType>
Simple "Least Recently Used" (LRU) cache.
The instance is an
Iterableof[key, value]pairs so you can use it directly in aforβ¦ofloop.