Skip to content

fundon/lruly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lruly

Implements an LRU cache.

var lruly = require('lruly');

var cache = lruly();
cache.add('foo', 'hello world');

Installation

$ npm install -g lruly

$ component install cfddream/lruly

Quick Start

Create the LRU cache and set maxEntries, if maxEntries is zero, the cache has no limit:

var cache = lruly(8964);

Add a entiry:

cache.add('module', { version: '0.0.1', name: 'lruly' });

Get the entry's value:

cache.get('module'); // { version: '0.0.1', name: 'lruly' }

Remove the entry by key:

cache.on('evicted', function (key, value) { /* do something */ });

cache.remove('module');

Get the number of entries in the cache:

cache.len();

Clean the cache:

cache.clean();

Running Tests

To run the test suite first invoke the following command within the repo, installing the development dependencies:

$ npm install

then run the tests:

$ make test

MIT License

About

lruly - implements an LRU cache.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published