@deepjs/cache

0.2.9 • Public • Published

cache

底层为 lru-cache 独立包,功能强大,使用简单

使用

https://github.com/isaacs/node-lru-cache

import { cache, LRU } from '@deepjs/cache'

const value = {temp: 'cache'}

cache.set('key', value, 60*5*1000)
cache.set('key', value)
cache.get('key')

const options = {
  max: 500,
  length: function (n, key) { return n * 2 + key.length },
  dispose: function (key, n) { n.close() },
  maxAge: 1000 * 60 * 60,
}
const cache1 = new LRU(option);
const cache2 = new LRU(50); // sets just the max size

cache1.set('key', value)
cache1.get('key') // "value"

Readme

Keywords

Package Sidebar

Install

npm i @deepjs/cache

Weekly Downloads

1

Version

0.2.9

License

MIT

Unpacked Size

2.19 kB

Total Files

3

Last publish

Collaborators

  • cloudyan