node-hoarder

1.0.2 • Public • Published

Node Hoarder

Your Slick Cache Library.

Quick Start

yarn add node-hoarder
import { FixedSizedCache } from 'node-hoarder';
 
const cache = new FixedSizedCache(100);
 
cache.set('message', 'Hello World');
 
const message = cache.get<string>('message');
 
console.log('message'); // => Hello World

Fixed Size Cache

The FixedSizedCache is a Least Recently Used Cache(LRU). The cache can store a fixed number of items in memory. When it's capacity is reached, the item that hasn't been used for the longest amount of time will be evicted.

The FixedSizedCache is great when you want to be able to control the memory consumption of your application.

class FixedSizeCache {
  constructor(size: number);
  get<T>(key: string): T;
  set(key: string, value: any): void;
}

Dependencies (0)

    Dev Dependencies (8)

    Package Sidebar

    Install

    npm i node-hoarder

    Weekly Downloads

    1

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    14.6 kB

    Total Files

    18

    Last publish

    Collaborators

    • artmann