Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": false
}
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

const IoRedis = require('ioredis');
const redisTimeout = require('ioredis-timeout');


function retryStrategy(times) {
Expand Down Expand Up @@ -32,10 +33,12 @@ class Redis {
* @param {string} name - unique name to this service
* @param {EventEmitter} emitter
* @param {Object} config - configuration object of service
* @param {number} commandTimeout - config for command timeout in ms
*/
constructor(name, emitter, config) {
constructor(name, emitter, config, commandTimeout) {
this.name = name;
this.emitter = emitter;
this.commandTimeout = commandTimeout;
this.config = Object.assign({
host: 'localhost',
port: 6379,
Expand Down Expand Up @@ -170,6 +173,7 @@ class Redis {
}

this.log(`Connecting in ${infoObj.mode} mode`, infoObj);
redisTimeout(client, this.commandTimeout);

// common events
client.on('connect', () => {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
},
"homepage": "https://github.com/akshendra/redis-wrapper#readme",
"dependencies": {
"ioredis": "^3.2.2"
"ioredis": "^3.2.2",
"ioredis-timeout": "^1.5.0"
},
"devDependencies": {
"eslint": "^5.9.0",
Expand Down