1.1.0 • Published 6 years ago

@kwiwk/lru-cached-getter v1.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

lru-cached-getter

A cache for asychnronous data.

Travis Coveralls github npm npm

Kwiwk Logo

Table Of Contents

Description

LRUCachedGetter will cache results retrieved through its getter function for faster access on subsequent calls.

Features:

  • First class TypeScript support!
  • Configurable expiration time
  • Configurable LRU cache size
  • Force updating

Getting Started

  • Install Node v8 LTS here.

Documentation

import { LRUCachedGetter } from "@kwiwk/lru-cached-getter";

// Create a new LRU cache
const lru = new LRUCachedGetter({
    getter: ([first, last]) => getPersonAsync(first, last), 
    hasher: (name) => JSON.stringify(name), 
    maxSize: 10,
    expiresMs: 1000 * 60 * 60 * 24
});

// Result cached for future retrievals.
let person = await lru.get(["Russley", "Shaw"]);

View the API docs here.

View the coverage report here.

License

View the license here.

Changelog

View the changelog here.