Tiny FIFO cache for Client or Server
const cache = fifo(max, ttl = 0);Clears the contents of the cache
return {Object} FIFO instance
Example
cache.clear();Removes item from cache
param {String} key Item key
return {Object} FIFO instance
Example
cache.delete("myKey");Evicts the first item from cache
return {Object} FIFO instance
Example
cache.evict();Gets item in cache
param {String} key Item key
return {Mixed} Undefined or Item value
Example
const item = cache.get("myKey");Returns an Array of cache item keys
return {Array} Array of keys
Example
console.log(cache.keys());Max items to hold in cache (1000)
Example
const cache = fifo(500);
cache.max; // 500Sets item in cache
param {String} key Item key
param {Mixed} value Item value
return {Object} FIFO instance
Example
cache.set("myKey", {prop: true});Number of items in cache
Example
const cache = fifo();
cache.size; // 0 - it's a new cache!Milliseconds an item will remain in cache; lazy expiration upon next get() of an item
Example
const cache = fifo();
cache.ttl = 3e4;Copyright (c) 2019 Jason Mulligan Licensed under the BSD-3 license.