IORedis store for node cache manager
Redis cache store for node-cache-manager.
This package is a almost identical to node-cache-manager-redis-store, but uses ioredis
instead of node_redis
. It aims to provide the most simple wrapper possible by just passing the configuration to the underlying ioredis
package.
Installation
npm install cache-manager-ioredis --save
or
yarn add cache-manager-ioredis
Usage Examples
See examples below on how to implement the IORedis cache store.
Single store
var cacheManager = ;var redisStore = ; var redisCache = cacheManager; // listen for redis connection error eventvar redisClient = redisCachestore; redisClient; var ttl = 5; redisCache; { ;} var userId = 123;var key = `user_`; // Note: ttl is optional in wrap()redisCache;
Multi-store
var cacheManager = ;var redisStore = ; var redisCache = cacheManager;var memoryCache = cacheManager; var multiCache = cacheManager; var userId2 = 456;var key2 = `user_`; // Set value in all cachesmultiCache; // Note: ttl is optional in wrapmultiCache;
Use Clustering (eg Amazon elasticache)
var cacheManager = ;var redisStore = ; // https://github.com/luin/ioredis#clustervar redisCache = cacheManager;
Use an external Redis Instance
var cacheManager = ;var redisStore = ;var Redis = ; var redisInstance = host: 'localhost' port: 6379 db: 0; var redisCache = cacheManager;
Contribution
Want to help improve this package? We take pull requests.
License
The node-cache-manager-ioredis
is licensed under the MIT license.