1.1.1 • Published 7 years ago
tiny-filo v1.1.1
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 instanceExample
cache.clear();delete
Method
Removes item from cache
param {String} key Item key
return {Object} FILO instanceExample
cache.delete("myKey");evict
Method
Evicts the last item from cache
return {Object} FILO instanceExample
cache.evict();get
Method
Gets item in cache
param {String} key Item key
return {Mixed} Undefined or Item valueExample
const item = cache.get("myKey");keys
Method
Returns an Array of cache item keys.
return {Array} Array of keysExample
console.log(cache.keys());max
Property
Max items to hold in cache (1000)
Example
const cache = filo(500);
cache.max; // 500set
Method
Sets item in cache
param {String} key Item key
param {Mixed} value Item value
return {Object} FILO instanceExample
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.