You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don’t want to block the program, even if an error occurs, but I want to keep on reconnect always.
In this case, does the code below look OK?
'use strict';letPromise=require('bluebird');letRedis=require('ioredis');letredis=newRedis({sentinels: [{host: '127.0.0.1',port: 15379},{host: '127.0.0.1',port: 15380},{host: '127.0.0.1',port: 15381}],name: 'mymaster',enableOfflineQueue: false,retryStrategy: function(times){if(times<3){return200;}}});Redis.Promise.onPossiblyUnhandledRejection(function(err){console.error(err);});letfunc=Promise.coroutine(function*(){letkey='foo:'+Math.random();// DO NOT STOP IF ERROR OCCURS, BUT KEEP ON RECONNECTtry{yieldredis.setex(key,10,'xxxxxxxxx');letvalue=yieldredis.get(key);console.log(Date.now(),value);}catch(err){console.error(err);}});letloop=function(){func().then(loop).catch(function(err){console.error(err.stack);process.exit(1);});}redis.on('end',function(){// Reconnect manually after finished all retryredis.connect();});redis.once('ready',function(){loop();});
The text was updated successfully, but these errors were encountered:
I don’t want to block the program, even if an error occurs, but I want to keep on reconnect always.
In this case, does the code below look OK?
The text was updated successfully, but these errors were encountered: