Naming Prosecution Mitigator
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

node-lru

0.0.2 • Public • Published

NPM

Node LRU Cache

基于Nodejs开发的LRU Cache, 兼有缓存超时清除功能

usage

var options = {
  expires: 5 * 60 * 1000,
  capacity: 5
};
var LRU = require('node-lru');
var cache = new LRU(2);//var cache = new LRU(options);
cache.set('key1', 'value1');
cache.set('key2', 'value2');
cache.set('key3', 'value3');

var value = cache.get('key2');

cache.on('extrusion', function (tail) {
  console.log(tail.key + ": " + tail.value);
});
cache.on('expired', function (element) {
  console.log(element.key + ": " + element.value);
});

Run tests

$ npm test

Keywords

install

npm i node-lru

Downloadsweekly downloads

225

version

0.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar