lrucache
LRU Cache for node.js/browser.

lrucache downloads lrucache version

lrucache유사 패키지:
npm 다운로드 트렌드
3 년
🌟 lrucache의 README.md에 실시간 사용 차트를 표시하려면 아래 코드를 복사하세요.
## Usage Trend
[![Usage Trend of lrucache](https://npm-compare.com/img/npm-trend/THREE_YEARS/lrucache.png)](https://npm-compare.com/lrucache#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 lrucache의 README.md에 GitHub Stars 트렌드 차트를 표시하려면 아래 코드를 복사하세요.
## GitHub Stars Trend
[![GitHub Stars Trend of lrucache](https://npm-compare.com/img/github-trend/lrucache.png)](https://npm-compare.com/lrucache)
통계 세부사항
패키지
다운로드
Stars
크기
Issues
발행일
라이선스
lrucache28,99612-08年前-
lrucache의 README

LRUCache

LRU Cache for node.js/browser.

NPM version Build Status Downloads

使用链表实现的 LRU 缓存。getsetupdate 方法会更新 LRU 优先级。

Install

Node.js:

npm install lrucache

bower:

bower install lrucache

Browser:

<script src="/pathTo/lrucache.js"></script>

API

const LRUCache = require('lrucache')

Class LRUCache([capacity])

  • capacity: : Optional, Type: Number, Default: Number.MAX_SAFE_INTEGER.
const cache = LRUCache(100)

LRUCache.prototype.get(key)

Return value.

let a = cache.get('a')

LRUCache.prototype.set(key, value)

Return this.

cache.set('a', [1, 2, 3])

LRUCache.prototype.update(key, fn)

Return this, It only run when key exists.

cache.update('a', function (a) {
  a.push(4)
  return a
})

LRUCache.prototype.remove(key)

Return this.

cache.remove('a')

LRUCache.prototype.removeAll(key)

Return this.

cache.removeAll()

LRUCache.prototype.keys()

Return a array of keys.

cache.keys()

LRUCache.prototype.has(key)

Return true or false.

cache.has('a')

LRUCache.prototype.staleKey()

Return the stalest key or null.

let staleKey = cache.staleKey()

LRUCache.prototype.popStale()

Return the stalest data or null.

let staleDate = cache.popStale()

LRUCache.prototype.info()

Return info.

cache.info()