@specialblend/lru-cache-pipe
v0.2.0
Published
functional wrapper around lru-cache
Downloads
11
Maintainers
Readme
@specialblend/lru-cache-pipe
functional wrapper around lru-cache
installation
npm install @specialblend/lru-cache-pipe
usage
import createCache from '@specialblend/lru-cache-pipe';
async function fetchTodoById (id) {
// IO intensive operation ...
}
const todoCache = createCache(fetchTodoById)
async function main() {
await todoCache.resolve('test-todo-id'); // => calls fetchTodoById with test-todo-id and caches the result
await todoCache.resolve('test-todo-id'); // => returns the cached result
await todoCache.resolve('fooBarId'); // => calls fetchTodoById with fooBarId and caches the result
await todoCache.resolve('fooBarId'); // => returns the cached result
}