1.0.0 • Published 2 years ago
punycache v1.0.0
punycache 🦴
A minimalist cache implementation.
Usage
const cache = require('punycache')()
cache.set('key', 'Hello World !')
console.log(cache.get('key')) // Hello World !
console.log(cache.keys()) // [ 'key' ]
console.del('key')
console.log(cache.get('key')) // undefinedOptions
const cache = require('punycache')({
ttl: 200,
max: 100,
policy: 'lfu'
})ttl: (default:Number.POSITIVE_INFINITY) Time to live in the cache, expressed in millisecondsmax: (default:Number.POSITIVE_INFINITY) Maximum number of keys to be stored in the cache (seepolicyfor cache replacement policies)policy: Cache replacement policy, supported values are'lru'(default) Least Recently Used (eachget/setupdates used timestamp)'lfu'Least Frequently Used (eachget/setincrements usage frequency)
Implementation notes :
- keys are expected to be strings but no validation is done
- Values are stored and returned as-is
- Keys are removed from the cache ad-hoc (no timeout is being used)
1.0.0
2 years ago