/ live.thehmm.nl / back / node_modules / ylru /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[TXT]History.md40 years ago1.4K 
[   ]LICENSE40 years ago1.1K 
[TXT]README.md40 years ago3.6Kd7c1522 post receive test [كارل مبارك]
[TXT]index.d.ts40 years ago356  
[   ]index.js40 years ago2.3K 
[   ]package.json2 years ago2.0K 
README.md

ylru

NPM version build status Test coverage Known Vulnerabilities npm download

hashlru inspired

hashlru is the Simpler, faster LRU cache algorithm. Please checkout algorithm and complexity on hashlru.

ylru extends some features base on hashlru:

Usage

const LRU = require('ylru');

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 });

API

LRU(max) => lru

initialize a lru object.

lru.get(key[, options]) => value | null

Returns the value in the cache.

lru.set(key, value[, options])

Set the value for key.

lru.keys()

Get all unexpired cache keys from lru, due to the strategy of ylru, the keys' length may greater than max.

const lru = new LRU(3);
lru.set('key 1', 'value 1');
lru.set('key 2', 'value 2');
lru.set('key 3', 'value 3');
lru.set('key 4', 'value 4');

lru.keys(); // [ 'key 4', 'key 1', 'key 2', 'key 3']
// cache: {
//   'key 4': 'value 4',
// }
// _cache: {
//   'key 1': 'value 1',
//   'key 2': 'value 2',
//   'key 3': 'value 3',
// }

License

MIT

Contributors


dominictarr


fengmk2


dead-horse


mourner


vagusX


RaoHai

This project follows the git-contributor spec, auto updated at Wed Mar 16 2022 23:57:13 GMT+0800.

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80