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