Sends PING commands to Redis using redis to check if the connection is alive by receiving a PONG within a certain timespan
npm install cinovo-redis-pingpong
var pingpong = require"cinovo-redis-pingpong";
var client = require"redis"createClient6379 "localhost";pingpongwatchclient "interval": 5000 "maxTimespan": 2000 "maxMissesBeforeError": 5;pingpongon"error"console.log"redis is not available";;pingpongstop;
Now your redis client is watched.
Watch a redis
client: Instance of redid.createClient()...
cfg: Object (optional)
interval: Number - Milli seconds between two PINGs (optional, default: 5000)
maxTimespan: Number - Milli seconds we wait for a PONG after the PING (optional, default: 2000)
maxMissesBeforeError: Number - If we counted $maxMissesBeforeError misses an error is emitted (optional, default: 5)
Stop the watcher.
Is fired when the PING command is send.
Is fired when the PONG response arrived.
timespan: Number - Time between PING and PONG in milli seconds
Is fired if redis was missed.
misses: Number . Number of misses so far
error: Error that caused the miss
Is fired when redis is no longer available.
If the watches was stopped.