A locking LRU cache that deduplicates concurrent calls to a cached function: if multiple requests arrive for the same key while the initial call is in-flight, they all wait and receive the cached result once available. Current version 0.4.1 wraps lru-cache to provide a lock/unlock mechanism. The package is minimal but stable, with no recent releases since 2016 (likely maintenance mode). Key differentiators: integrates locking semantics on top of any compatible LRU cache, supports custom factory functions for alternative cache backends, and passes varargs through to all pending callbacks.
npm install locking-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a locking cache and demonstrates deduplication: second fetch waits for first and receives cached result.
Access values as an array, e.g., function(key, values) { console.log(values[0], values[1]); }.Use require() or configure bundler to handle CommonJS modules.
Consider migrating to a more modern library like async-lru or p-limit with memoization.
Invoke lockingCache with an options object or a factory function: var locked = lockingCache({ max: 10 });Ensure the function passed to lockedFetch() returns the result of lock(key, cb) as shown in the usage.
The dispose callback receives an array of values: function(key, values) { ... }