@kwiwk/lru-cached-getter
v1.1.0
Published
LRU Cached asynchronous data getter.
Downloads
2
Readme
lru-cached-getter
A cache for asychnronous data.
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.