LRUCache

LRUCache

Implements an LRUCache using the ES6 Map.prototype and not a custom doubly linked list. Cache Strategies on Wikipedia

Constructor

new LRUCache(options)

Creates a LRUCache.
Parameters:
Name Type Description
options Object | Number object of options or number thats set on this.max.
Source:

Methods

clear() → {LRUCache}

clears all keys and values from the store and sets size to 0
Source:
Returns:
this instance
Type
LRUCache

delete() → {LRUCache}

Deletes a key/value pair from any where in the cache.
Source:
Returns:
this instance
Type
LRUCache

get(key) → {*}

Returns a value from the cache associated with a key.
Parameters:
Name Type Description
key * Can be objects or primitive values.
Source:
Returns:
Can be objects and primitive values.
Type
*

set(key, value) → {LRUCache}

Sets a key and its value in the cache at the most recent position/last index
Parameters:
Name Type Description
key * Can be objects or primitive values.
value * Can be objects or primitive values.
Source:
Returns:
this instance
Type
LRUCache

updateMax(newMax) → {LRUCache}

Updates the max capacity of the cache. If the max capacity of the cache is less than the current max capacity and the cache is at max capacity, the cache will shed the older items.
Parameters:
Name Type Description
newMax number The value that will be the new max capacity for the cache.
Source:
Returns:
This instance.
Type
LRUCache