Last active
September 16, 2015 17:16
-
-
Save fatso83/e08a6755d46bd94193ee to your computer and use it in GitHub Desktop.
Shows how Redis is behaving when disconnecting and connecting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 'connected' | |
5007 'getting key' | |
5881 'ended' | |
5882 'reconnecting' { delay: 255, attempt: 2 } | |
6143 'error' [Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED] | |
6144 'reconnecting' { delay: 433, attempt: 3 } | |
6580 'error' [Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED] | |
6580 'reconnecting' { delay: 736, attempt: 4 } | |
7319 'error' [Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED] | |
7319 'reconnecting' { delay: 1251, attempt: 5 } | |
8014 'getting key' | |
8574 'Got error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED' | |
8575 'error' [Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED] | |
8575 'reconnecting' { delay: 2126, attempt: 6 } | |
10703 'connected' | |
11019 'getting key' | |
11591 'ended' | |
11591 'reconnecting' { delay: 255, attempt: 2 } | |
11851 'error' [Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED] | |
11851 'reconnecting' { delay: 433, attempt: 3 } | |
12290 'error' [Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED] | |
12291 'reconnecting' { delay: 736, attempt: 4 } | |
13030 'error' [Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED] | |
13031 'reconnecting' { delay: 1251, attempt: 5 } | |
14024 'getting key' | |
14286 'connected' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var r = require('redis'); | |
var rc = r.createClient(); | |
var start = Date.now(); | |
function now(){ | |
return Date.now()-start; | |
} | |
function log() { | |
var args = [].slice.call(arguments,0) | |
console.log.apply(console, [now()].concat(args)); | |
} | |
rc.on('connect', log.bind(null,'connected')); | |
rc.on('reconnecting', log.bind(null,'reconnecting')); | |
rc.on('error', log.bind(null,'error')); | |
rc.on('end', log.bind(null,'ended')); | |
setTimeout(function(){ | |
setInterval(function() { | |
log('getting key'); | |
rc.get("some key", function(err,res) { | |
if(err) { log('Got error: ' + err.message); } | |
}); | |
},3000); | |
},2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment