A Redis-backed LRU cache for Node.js, version 0.6.0. It allows caching that persists across process restarts and is shareable between multiple Node.js processes via Redis. The API is inspired by node-lru-cache and supports both node_redis and ioredis clients. Offers configurable options such as max size, namespace, maxAge, custom scoring, and incremental scoring (usable as LFU). All methods return Promises. Compared to in-memory LRU caches, this provides durability and sharing, at the cost of network latency. Active development, with a steady release cadence (latest: 0.6.0).
npm install redis-lruNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create, use, and see eviction in a Redis-backed LRU cache with both in-memory and TTL expiry.
Use .then() or async/await on all cache methods.
Use 'namespace' instead of 'prefix'.
Ensure values are JSON-serializable. Use a custom serialize/deserialize approach if needed.
Always pass string keys to avoid unexpected behavior.
Monitor Redis performance; consider partitioning or using an in-memory LRU for high-throughput scenarios.
Call lru(client, options) without 'new'.
const cache = lru(client, { max: 5 });Update to v0.5.0+ and use Promises. Or check the version in package.json.
Ensure the 'score' function returns a number (e.g., Date.now()).
Provide a valid string for 'namespace'.
No dependency data recorded yet.