xache
Yet another auto expiring, max sizable cache
Last updated 2 years ago by mafintosh .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install xache 
SYNC missed versions from official npm registry.

xache

Yet another auto expiring, max sizable cache

npm install xache

Usage

const Xache = require('xache')

const cache = new Xache({
  maxSize: 10, // at max (ish) have 10 entries
  maxAge: 100, // auto expire entries after (ish) 100ms
  createMap () { // optional function to create backing storage
    return new Map()
  }
})

// When maxSize is hit, the oldest entries are removed
// cache has the same api as a map

cache.set('hello', 'world')
console.log(cache.get('hello'))

console.log(...cache) // iterable!

That's it, nice and simple.

License

MIT

Current Tags

  • 1.1.0                                ...           latest (2 years ago)

2 Versions

  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)

Copyright 2013 - present © cnpmjs.org | Home |