An in-memory cache backed by Redis with pub/sub updates, version 1.1.0. Designed for applications needing low-latency access to Redis-stored data with real-time invalidation. Uses an LRU cache internally, supports key generation and deserialization functions, and offers multiple error handling and update strategies. Unlike simple Redis caching, it subscribes to channels to automatically update or evict cached items upon data changes, reducing server load and ensuring freshness. Suitable for TypeScript projects, ships types, and requires a Redis server for reading and pub/sub.
npm install redis-value-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a RedisValueCache with a shared Redis client, subscribes to pattern 'cache:*', gets values via GET, and deserializes JSON.
Ensure deserialize never returns null/undefined; handle in fallbackFetchMethod if needed.
Set freeze: false if you need to mutate cached objects.
Set errorHandlerStrategy: 'throw' during development to catch errors early.
Use with caution; test upgrade paths when releasing new versions.
Always await cache.init() before any get() calls.
Provide a proper ioredis or node-redis client, or supply redis.clientOpts instead of a raw client.
Await client.connect() before passing to RedisValueCache, or pass redis.clientOpts to let the library handle connection.
Ensure genKeyFromMsg always returns a string key; log or handle cases where it might return undefined.
Set errorHandlerStrategy: 'throw' or 'emit' to handle errors, or increase Redis timeout.