lrumap

A Map of limited size that keeps most recently used values

  • lrumap

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
lrumap
1.0.06 years ago6 years agoMinified + gzip package size for lrumap in KB

Readme

TupleMap npm version Build Status Dependency Status Coverage Status
A Map of limited size that keeps most recently used values. This lib is one of the several possible cache for memoize-immutable, but it can suit other use-cases as it implements a usual Map API.

Install

npm install --save LRUMap
This lib has no dependency, but requires a native implementation of Map.

Usage

var LRUMap = require('LRUMap');

// The default size limit of the map is 10.000
var cache = new LRUMap({ limit: 10000 });

var key = 'Carole';
var value = {any: 'thing'};

cache.set(key, value);

cache.has(key) === true;
cache.get(key) === value;

When should you use this map?

This map should be used as an alternative to a native Map, when you need to limit its size.

Author

@louisremi

License

MPL-2.0