lfu
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

lfu

LFU (Least Frequently Used) implementation, written in Rust provided as WebAssembly module, using a min-heap, that is, a basic vector, and a hashmap for storage of indices to keep track of cache blocks to allow for constant-time searches.

Build

$ make

Usage

$ yarn add lfu
const Lfu = require("lfu").Lfu;

const lfu = new Lfu(4);

lfu.refer("1"); // insert 1
lfu.refer("2"); // insert 2
lfu.refer("1"); // incr 1
lfu.refer("3"); // insert 3
lfu.refer("2"); // incr 2
lfu.refer("4"); // insert 4
lfu.refer("5"); // remove 3, insert 5

lfu.clear();

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i lfu

      Weekly Downloads

      30

      Version

      0.2.1

      License

      none

      Unpacked Size

      21.4 kB

      Total Files

      7

      Last publish

      Collaborators

      • kenansulayman