lruly

lruly implements an LRU cache.

Usage no npm install needed!

<script type="module">
  import lruly from 'https://cdn.skypack.dev/lruly';
</script>

README

lruly

Implements an LRU cache.

var lruly = require('lruly');

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

Installation

$ npm install -g 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 entiry by key:

cache.remove('module');

Get the number of entries in the cache:

cache.len();