{"id":45322,"library":"locking-cache","title":"locking-cache","description":"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.","status":"maintenance","version":"0.4.1","language":"javascript","source_language":"en","source_url":"https://github.com/mojodna/node-locking-cache","tags":["javascript"],"install":[{"cmd":"npm install locking-cache","lang":"bash","label":"npm"},{"cmd":"yarn add locking-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add locking-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the underlying LRU cache storage and eviction policy.","package":"lru-cache","optional":false}],"imports":[{"note":"Package is CJS only; ESM import may fail depending on bundler. Use require() or wrap with default interop.","wrong":"import lockingCache from 'locking-cache';","symbol":"lockingCache","correct":"var lockingCache = require('locking-cache');"},{"note":"lockingCache is a function, not a constructor. Calling with 'new' will not cause an error but is unnecessary.","wrong":"var locked = new lockingCache(options);","symbol":"lockingCache (factory)","correct":"var locked = lockingCache(options);"},{"note":"The dispose callback receives an array of values (to support varargs from unlock()), not a single value like in standard lru-cache.","wrong":"lockingCache({ dispose: function(key, value) { ... } });","symbol":"dispose callback","correct":"lockingCache({ dispose: function(key, values) { ... } });"}],"quickstart":{"code":"var lockingCache = require('locking-cache');\nvar request = require('request');\n\nvar lockedFetch = lockingCache({ max: 10 });\n\nvar fetch = lockedFetch(function(uri, lock) {\n  var key = uri;\n  return lock(key, function(unlock) {\n    return request.get(uri, function(err, rsp, body) {\n      return unlock(err, rsp, body);\n    });\n  });\n});\n\nfetch('http://example.com/', function(err, rsp, body) {\n  console.log(err, rsp.statusCode, body.length);\n});\n\nfetch('http://example.com/', function(err, rsp, body) {\n  console.log('Cached response:', rsp.statusCode, body.length);\n});","lang":"javascript","description":"Creates a locking cache and demonstrates deduplication: second fetch waits for first and receives cached result."},"warnings":[{"fix":"Access values as an array, e.g., function(key, values) { console.log(values[0], values[1]); }.","message":"The dispose callback receives an array of values instead of a single value.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use require() or configure bundler to handle CommonJS modules.","message":"Package is CJS only; ESM imports may not work without a bundler interop.","severity":"breaking","affected_versions":"*"},{"fix":"Consider migrating to a more modern library like async-lru or p-limit with memoization.","message":"The package has not been updated since 2016; relies on older lru-cache versions.","severity":"deprecated","affected_versions":"*"}],"env_vars":null,"search_vec":"'0.4.1':44 '2016':65 'altern':86 'arriv':19 'avail':41 'backend':88 'cach':3,7,14,38,48,80,87 'call':11,27 'callback':96 'compat':78 'concurr':10 'current':42 'custom':82 'dedupl':9 'differenti':70 'factori':83 'flight':31 'function':15,84 'in-flight':29 'initi':26 'integr':71 'javascript':97 'key':23,69 'like':66 'lock':2,5,72 'lock/unlock':52 'locking-cach':1 'lru':6,47,79 'lru-cach':46 'mainten':67 'mechan':53 'minim':57 'mode':68 'multipl':17 'packag':55 'pass':90 'pend':95 'provid':50 'receiv':36 'recent':62 'releas':63 'request':18 'result':39 'semant':73 'sinc':64 'stabl':59 'support':81 'top':75 'vararg':91 'version':43 'wait':34 'wrap':45","created_at":"2026-06-07T12:54:26.704194+00:00","updated_at":"2026-06-07T12:54:26.704194+00:00","problems":[{"fix":"Invoke lockingCache with an options object or a factory function: var locked = lockingCache({ max: 10 });","cause":"Calling lockingCache without passing a factory callback or options object.","error":"TypeError: locked is not a function"},{"fix":"Ensure the function passed to lockedFetch() returns the result of lock(key, cb) as shown in the usage.","cause":"The user-provided function does not return a lock() call.","error":"TypeError: lock is not a function"},{"fix":"The dispose callback receives an array of values: function(key, values) { ... }","cause":"Passing dispose in options without wrapping values in array.","error":"Error: dispose is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/mojodna/node-locking-cache#readme","github":"https://github.com/mojodna/node-locking-cache","docs":null,"changelog":null,"pypi":null,"npm":"locking-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}