CacheMap
src/CacheMap.js:21-172A TTL cache with an API compatible with an ES6 Map. Requires node 6+.
constructor
src/CacheMap.js:39-59Parameters
ttl
number The TTL for all entries added to this mapevictInterval
number? How frequently to delete expired entries from the internal
map
intialValues
Iterable<\[K, V>? An iterable such as an array or another map
containing the initial values to set in the map
Returns void clear
src/CacheMap.js:64-66Removes all key/value pairs from the Map object.
Returns void
delete
src/CacheMap.js:72-74Removes any value associated with that key
Parameters
key
K the key to delete
Returns boolean
entries
src/CacheMap.js:80-87Returns Iterator<\[K, V> a new iterator object that contains an array of key, value for each element in the map that has not expired
forEach
src/CacheMap.js:94-98Calls fn once for each non-expired key-value pair in the map object
Parameters
fn
function (value: V, index: K, map: any): any the function to callthisArg
any the value of this when fn is called
Returns void
get
src/CacheMap.js:104-110Parameters
key
K
Returns V? the value associated with the key, or undefined if there is none or that entry has expired
has
src/CacheMap.js:115-120Parameters
key
K
Returns boolean indicates if the key has an associated value which hasn't expired
keys
src/CacheMap.js:125-129Returns Iterator<K> a new iterator containing the keys of each non-expired entry in the map
set
src/CacheMap.js:135-138Sets the value in the map, with a ttl of Date.now() + map.ttl
Parameters
key
Kvalue
V
Returns any the map
size
src/CacheMap.js:143-145The number of non-expired key/value pairs in the map
Returns number
values
src/CacheMap.js:150-154Returns Iterator<V> a new iterator containing the values of each non-expired entry in the map
deleteExpired
src/CacheMap.js:159-163Removes every entry from the internal map that has already expired
Returns void