tiny-lfu-cache

Simple LFU cache. put and get.

Usage no npm install needed!

<script type="module">
  import tinyLfuCache from 'https://cdn.skypack.dev/tiny-lfu-cache';
</script>

README

NPM version"> Build Status Dependency Status

Simple LFU cache. put and get.

Suitable for use in browsers and Node.js.

Install

$ npm install --save tiny-lfu-cache

Usage

var LRUCache = require('tiny-lfu-cache');

var maxSize = 100;
var cache = new LFUCache(maxSize);
cache.put('key', 'value');
cache.get('key'); // returns 'value'

cache.flush(); // Empties the cache

LFU Eviction Policy

Once the cache reaches its maximum size, the least frequently used (LFU) item is evicted.

If items in the cache have equal frequency of use, then the least recently used (LRU) item is evicted.

Development

npm install
npm test

License

MIT © Andy Hume