0.2.0 • Published 4 years ago

@specialblend/lru-cache-pipe v0.2.0

Weekly downloads
7
License
ISC
Repository
github
Last release
4 years ago

@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
}
0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.3

4 years ago

0.0.2

5 years ago

0.0.1

5 years ago