https://github.com/mafintosh/xache
Yet another auto expiring, max sizable cache
https://github.com/mafintosh/xache
Last synced: about 1 month ago
JSON representation
Yet another auto expiring, max sizable cache
- Host: GitHub
- URL: https://github.com/mafintosh/xache
- Owner: mafintosh
- License: mit
- Created: 2021-05-21T20:19:10.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-07T22:07:23.000Z (over 1 year ago)
- Last Synced: 2025-04-07T18:46:39.551Z (about 2 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 50
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-github-repos - mafintosh/xache - Yet another auto expiring, max sizable cache (JavaScript)
README
# xache
Yet another auto expiring, max sizable cache
```
npm install xache
```## Usage
``` js
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 mapcache.set('hello', 'world')
console.log(cache.get('hello'))console.log(...cache) // iterable!
```That's it, nice and simple.
## License
MIT