LRUDictionary<K, V> Class

A LRUCache using a Dictionary as its internal storage, permitting custom key comparison logic.

Extends

Methods

Name Description
constructor(limit: number, compareKeys: OrderedComparator<K>): LRUDictionary Construct a new LRUDictionary to hold up to limit entries.  

Inherited methods

Name Inherited from Description
assign(entries: Iterable<[K, V]>): void LRUCache<K, V> Replace all values in this cache with key-value pairs (2-element Arrays) from provided iterable.
clear(): void LRUCache<K, V> Removes all entries
delete(key: K): V | undefined LRUCache<K, V> Remove entry key from cache and return its value.
entries(): Iterator<[K, V] | undefined> | undefined LRUCache<K, V> Returns an iterator over all entries, starting with the oldest.
find(key: K): V | undefined LRUCache<K, V> Access value for key without registering recent use.
forEach(fun: (value: V, key: K, m: LRUCache<K, V>) => void, thisObj?: any): void LRUCache<K, V> Call fun for each entry, starting with the oldest entry.
get(key: K): V | undefined LRUCache<K, V> Get and register recent use of .
has(key: K): boolean LRUCache<K, V> Check if there's a value for key in the cache without registering recent use.
keys(): Iterator<K | undefined> | undefined LRUCache<K, V> Returns an iterator over all keys, starting with the oldest.
set(key: K, value: V): LRUCache<K, V> LRUCache<K, V> Put into the cache associated with .
shift(): [K, V] | undefined LRUCache<K, V> Purge the least recently used (oldest) entry from the cache.
toJSON(): Array<object> LRUCache<K, V> Returns a JSON (array) representation
toString(): string LRUCache<K, V> Returns a String representation
values(): Iterator<V | undefined> | undefined LRUCache<K, V> Returns an iterator over all values, starting with the oldest.

Inherited properties

Name Type Inherited from Description
limit number LRUCache<K, V> Maximum number of items this cache can hold
newest undefined | Entry<K, V> LRUCache<K, V> Most recently-used entry.
oldest undefined | Entry<K, V> LRUCache<K, V> Least recently-used entry.
size number LRUCache<K, V> Current number of items

Defined in

Last Updated: 20 September, 2019