Node.js cache wrapper that asynchronously refreshes cached entries to minimize cache misses and prevent staleness. Current version 2.2.1 releases maintain a steady cadence. Requires ioredis for Redis backend and optionally supports multi-level caching with lru-cache for local memory. Key differentiator: proactive buffer-based refresh strategy rather than passive expiry, keeping hot data fresh with zero additional latency.
npm install buffering-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a BufferingCache instance with Redis and optional local cache, wraps a function to be cached, then calls it.
Always provide a valid ioredis client as the 'redisClient' option.
Ensure ttlMsec is a positive number (e.g., 5000).
Set bufferTtlMsec to a value between 1 and ttlMsec-1, or omit to use default (ttlMsec/2).
Set localCacheSize to 0 (default) or a positive integer.
Use CommonJS require() instead of import.
Ensure you pass a valid ioredis instance: new BufferingCache({ redisClient: new Redis(/*...*/), ... })Provide ttlMsec as a number >= 0 in the configuration object.
Set bufferTtlMsec to a value between 1 and ttlMsec-1, or omit to use default.
Use const BufferingCache = require('buffering-cache');