The smallest and fastest TTL cache implementation in JavaScript
npm install yocto-ttl-cache










The smallest and fastest TTL cache implementation in JavaScript
- Usage
- Install
- API
- Sponsors
- Backers
- Changelog
- License
``shpnpm
pnpm add yocto-ttl-cache
$3
`js
import { TTLCache } from 'yocto-ttl-cache' // only named export is supportedconst cache = new TTLCache(1000) // the
ttl option of constructor is 1000 by defaultcache.get('key') //
undefined
cache.get('key', () => 'value') // get with setter, 'value'
cache.get('key', () => 'unused') // 'value' is not stalecache.set('key', 'newValue')
cache.get('key') //
'newValue'setTimeout(() => {
cache.get('key') //
undefined, stale after ttl
}, 1000)
``| 1stG | RxTS | UnTS |
| ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|  |  |  |
| 1stG | RxTS | UnTS |
| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|  |  |  |
Detailed changes for each release are documented in CHANGELOG.md.
[MIT][] © [JounQin][]@[1stG.me][]
[1stg.me]: https://www.1stg.me
[jounqin]: https://GitHub.com/JounQin
[mit]: http://opensource.org/licenses/MIT