Bluecache is a read-through, in-memory, least recently used (LRU) cache for Node.js. Version 4.1.3 wraps the popular lru-cache library and adds a Promise-based API that combines get and set into a single call, preventing cache stampedes by immediately caching and returning a Promise for the priming value. It supports options like max, maxAge (with ms string parsing), stale, custom length, dispose, and a pruneInterval for proactive stale entry removal. The cache is lazily enforced and stores a memo while the value resolves. It has a stable release cadence and is suited for simple in-memory caching in Node.js applications.
npm install bluecacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic instantiation with options, read-through caching with Promise-returning function, cache hit/miss behavior, deletion, and reset.
Use cache(key, primingValue) instead of a separate get/set pattern.
Pass pruneInterval option (in ms) to the cache constructor to periodically clean expired entries.
Allow headroom in the max setting or monitor pending promises to avoid excessive memory usage.
Call Bluecache(options) without `new`.
Migrate from `cache.get(key).then(...)` to `cache(key, primingValue).then(...)`. Refer to the readme for new API.
Change to `const cache = Bluecache(options);`
Use a valid ms string like '1h', '30m', or a number in milliseconds.
Use cache(key, primingValue) directly; for delete and reset use cache.del() and cache.reset().