Gathering detailed insights and metrics for cache-manager-ioredis
Gathering detailed insights and metrics for cache-manager-ioredis
Gathering detailed insights and metrics for cache-manager-ioredis
Gathering detailed insights and metrics for cache-manager-ioredis
@types/cache-manager-ioredis
TypeScript definitions for cache-manager-ioredis
@tirke/node-cache-manager-ioredis
[![npm version](https://badge.fury.io/js/@tirke%2Fnode-cache-manager-ioredis.svg)](https://badge.fury.io/js/@tirke%2Fnode-cache-manager-ioredis)
@anchan828/nest-cache-manager-ioredis
cache-manager
Cache Manager for Node.js
npm install cache-manager-ioredis
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
59 Stars
22 Commits
29 Forks
1 Watching
2 Branches
2 Contributors
Updated on 04 Jul 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-5.3%
10,687
Compared to previous day
Last week
-0.1%
61,243
Compared to previous week
Last month
-0%
264,732
Compared to previous month
Last year
8.3%
3,324,444
Compared to previous year
1
4
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.
1npm install cache-manager-ioredis --save
or
1yarn add cache-manager-ioredis
See examples below on how to implement the IORedis cache store.
1var cacheManager = require('cache-manager'); 2var redisStore = require('cache-manager-ioredis'); 3 4var redisCache = cacheManager.caching({ 5 store: redisStore, 6 host: 'localhost', // default value 7 port: 6379, // default value 8 password: 'XXXXX', 9 db: 0, 10 ttl: 600 11}); 12 13// listen for redis connection error event 14var redisClient = redisCache.store.getClient(); 15 16redisClient.on('error', (error) => { 17 // handle error here 18 console.log(error); 19}); 20 21var ttl = 5; 22 23redisCache.set('foo', 'bar', { ttl: ttl }, (err) => { 24 if (err) { 25 throw err; 26 } 27 28 redisCache.get('foo', (err, result) => { 29 console.log(result); 30 // >> 'bar' 31 redisCache.del('foo', (err) => { 32 }); 33 }); 34}); 35 36function getUser(id, cb) { 37 setTimeout(() => { 38 console.log("Returning user from slow database."); 39 cb(null, { id: id, name: 'Bob' }); 40 }, 100); 41} 42 43var userId = 123; 44var key = `user_${userId}`; 45 46// Note: ttl is optional in wrap() 47redisCache.wrap(key, (cb) => { 48 getUser(userId, cb); 49}, { ttl: ttl }, (err, user) => { 50 console.log(user); 51 52 // Second time fetches user from redisCache 53 redisCache 54 .wrap(key, () => getUser(userId)) 55 .then(console.log) 56 .catch(err => { 57 // handle error 58 }); 59});
1var cacheManager = require('cache-manager'); 2var redisStore = require('cache-manager-ioredis'); 3 4var redisCache = cacheManager.caching({ store: redisStore, db: 0, ttl: 600 }); 5var memoryCache = cacheManager.caching({ store: 'memory', max: 100, ttl: 60 }); 6 7var multiCache = cacheManager.multiCaching([memoryCache, redisCache]); 8 9var userId2 = 456; 10var key2 = `user_${userId2}`; 11 12// Set value in all caches 13multiCache.set('foo2', 'bar2', { ttl: ttl }, (err) => { 14 if (err) { 15 throw err; 16 } 17 18 // Fetches from highest priority cache that has the key 19 multiCache.get('foo2', (err, result) => { 20 console.log(result); 21 22 // Delete from all caches 23 multiCache.del('foo2'); 24 }); 25}); 26 27// Note: ttl is optional in wrap 28multiCache.wrap(key2, (cb) => { 29 getUser(userId2, cb); 30}, (err, user) => { 31 console.log(user); 32 33 // Second time fetches user from memoryCache, since it's highest priority. 34 // If the data expires in the memory cache, the next fetch would pull it from 35 // the 'someOtherCache', and set the data in memory again. 36 multiCache.wrap(key2, (cb) => { 37 getUser(userId2, cb); 38 }, (err, user) => { 39 console.log(user); 40 }); 41});
1var cacheManager = require('cache-manager'); 2var redisStore = require('cache-manager-ioredis'); 3 4// https://github.com/luin/ioredis#cluster 5var redisCache = cacheManager.caching({ 6 store: redisStore, 7 clusterConfig: { 8 nodes: [ 9 { 10 port: 6380, 11 host: '127.0.0.1' 12 }, 13 { 14 port: 6381, 15 host: '127.0.0.1' 16 } 17 ], 18 options: { 19 maxRedirections: 16 20 } 21 } 22});
1var cacheManager = require('cache-manager'); 2var redisStore = require('cache-manager-ioredis'); 3var Redis = require('ioredis'); 4 5var redisInstance = new Redis({ 6 host: 'localhost', 7 port: 6379, 8 db: 0, 9}); 10 11var redisCache = cacheManager.caching({ 12 store: redisStore, 13 redisInstance: redisInstance 14});
Want to help improve this package? We take pull requests.
The node-cache-manager-ioredis
is licensed under the MIT license.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
9 existing vulnerabilities detected
Details
Reason
Found 1/18 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More