cache-manager-ioredis provides a Redis store for the `node-cache-manager` library, leveraging the `ioredis` client for connecting to Redis. The package, currently at version 2.1.0, integrates `ioredis` by transparently passing configuration options to the underlying client, aiming for a simple wrapper. It differentiates itself from `node-cache-manager-redis-store` by opting for `ioredis` over `node_redis`, which offers better performance and features like Redis Cluster support. While this specific package's last update mentioned in the prompt is v2.1.0, the broader `cache-manager` ecosystem has evolved, with the main `cache-manager` library (v6+) now recommending `Keyv` as its primary storage adapter and explicitly moving away from direct support for `cache-manager-ioredis` and its 'yet' variants. This means `cache-manager-ioredis` is primarily suitable for older `node-cache-manager` versions or projects where `ioredis` integration is specifically required without migrating to `Keyv` adapters. Its release cadence is infrequent, reflecting its mature but superseded status within the evolving `cache-manager` landscape.
npm install cache-manager-ioredisVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `cache-manager` with `cache-manager-ioredis` as the store, perform basic set, get, and delete operations, and use the `wrap` function for memoization. It also includes essential error handling for Redis connection issues.
Review `ioredis` v3.0.0 release notes and adjust any direct `ioredis` client interactions. Prioritize using the `cache-manager` API methods instead of direct client calls where possible.
For new projects or upgrades to `cache-manager` v6+, consider migrating to `@keyv/redis` or using `KeyvAdapter` to wrap `cache-manager-ioredis` if necessary. Consult the latest `cache-manager` documentation for recommended practices.
Always attach an error listener to the `ioredis` client instance obtained via `redisCache.store.getClient().on('error', handler)`. Implement robust error handling, such as logging the error, falling back to a database, or implementing retry logic. Avoid letting unhandled `ioredis` errors crash your Node.js process.Ensure the Redis server is running and accessible from your application's environment. Verify the `host` and `port` configuration options for `cache-manager-ioredis`. If using a non-default hostname, check your `/etc/hosts` file or DNS settings.
Verify that `cache-manager-ioredis` is correctly installed (`npm install cache-manager-ioredis`) and that `redisStore` is imported and passed as the `store` option: `caching({ store: redisStore, ... })`.Include the `password` option in your `cache-manager-ioredis` configuration with the correct Redis password: `caching({ store: redisStore, password: 'your_redis_password', ... })`. Consider using environment variables for sensitive credentials.