1.1.1 • Published 3 years ago

memory-cacher v1.1.1

Weekly downloads
2,486
License
BSD-2-Clause
Repository
github
Last release
3 years ago

memory-cacher

get value from cache or from asynchronous getter, it will also call the promise only once in case it will ask for the same key more than once

Usage

@param {string} key @param {asynchronous function} fn @param {int} expiration

const MemoryCacher = require('memory-cacher');

const key = 'key';

let result = await MemoryCacher.getCached(key);

// result === null

result = await MemoryCacher.getCached(key, async () => {
  await delay(100);
  return 10;
}, 200);

// result === 10

result = MemoryCacher.getCached(key);

// result === 10
1.1.1

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago