llrruu

1.0.1 • Public • Published

lru

LRU (Least Recently Used) Cache.

  • single file
  • browser✔
  • Node.js✔
  • dependencies
  • babel
  • polyfills

Installation

npm install --save llrruu

Usage

import

const LRU = require('llrruu');

create

The module exported is both a constructor and a factory function. It accepts either a number or an object.

const lru1 = new LRU(10);
const lru2 = LRU(10);
const lru3 = LRU({
    maxSize: 10,
    onEvict: (key, val) => console.log(`${key} is being kicked out, with its value `, val)
});

api

lru.set('a', 1);    // will affect the order
lru.get('a');       // will affect the order
lru.val('a', 1);
lru.val('a');
lru.remove('a');
lru.keys();
lru.size();
lru.clear();

License

MIT

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i llrruu

    Weekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    6.91 kB

    Total Files

    5

    Last publish

    Collaborators

    • hengwu