A composite cache that combines an in-memory LRU layer with a Redis backend, using Redis pub/sub to stay synchronized across multiple processes or cluster nodes. Version 1.0.16 is the latest stable release, with no recent updates since its initial publish. It provides configurable LRU size, Redis TTL, and optional automatic clearing on instantiation. Differentiators include built-in cluster awareness without external coordination and an optional retrieveItem callback for lazy-loading missing keys. Requires Redis server 2.8.3+ and the `redis` npm package v2.x.
npm install redis-lru-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of redis-lru-cache: instantiation, set, get, and remove operations with required callbacks.
Install redis@2.x: npm install redis@^2.8
Wrap calls with util.promisify or use a promise wrapper.
Set `clear: false` on instantiation to avoid accidental flushing.
Use a unique identifier per process (e.g., process.pid + random string).
Always provide a callback function even if you do nothing with it.
Start Redis server: redis-server, or verify connection settings.
Provide a callback: cache.set(key, value, (err, result) => { ... })Ensure redis@2.x is installed and the dependency is properly required. The instance is created synchronously but the internal client may not be ready; use the callback in set/get to catch errors.