Skip to content

zcorky/lru

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published