Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@zcorky/lru

zcorky475MIT1.0.5TypeScript support: included

A tiny and fast Leat Recently Used(LRU) cache, written by typescript

zcorky, lru, cache, memoryCache, redis, ylru, flru, typescript

readme

lru

NPM version NPM quality Coverage Status Dependencies Build Status Known Vulnerabilities NPM download license issues

A tiny and fast Leat Recently Used(LRU) cache, written by typescript. Supports "expire" and "hits".

Install

$ npm install @zcorky/lru

Usage

const LRU = require('@zcorky/lru').lru;
// import LRU from '@zcorky/lru'; // ts or es6

const lru = new LRU(100);
lru.set(key, value);
lru.get(key);

// value2 will be expired after 5000ms
lru.set(key2, value2, { maxAge: 5000 });
// get key and update expired
lru.get(key2, { maxAge: 5000 });

// hits
lru.hits(); // { count, rate }

Relative Reposities

  • ylru: Add "expire", "allow set empty value" extends on hashlru.
  • flru: A tiny (215B) and fast Least Recently Used (LRU) cache.

License

MIT © Moeover