1.0.9 • Published 7 years ago

lru-cache-promise v1.0.9

Weekly downloads
257
License
MIT
Repository
github
Last release
7 years ago

lru-cache-promise

lru-cache with promises

This library wraps Isaac Z. Schlueter's lru-cache and adds a getAsync function.

Usage:

var cache = require("lru-cache-promise")();

var fetchFunction = function(key) {
  /* Do something async here to fetch the value */
};

cache.getAsync("some key", fetchFunction)
.then(function(value) { console.log(value) });

getAsync returns an A+ (specifically bluebird) promise.

  • If the value has already been cached, the promise will resolve immediately
  • If not, fetchFunction will be called with the requested key. fetchFunction must return either a concrete value or a promise.

getAsync ensures only one call to fetchFunction for a given key, allowing the calling code to be make many concurrent calls for the same key without negatively impacting the system from which the values are fetched.

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago