redis-watchtower

A client library for Redis Sentinel

Redis-Watchtower

A node.js client library for Redis Sentinel

npm install redis-watchtower

First of all reference redis-watchtower as follows:

var watchtower = require('redis-watchtower');

Connect to Redis Sentinel, passing in details of your sentinel servers:

var settings = {
    masterName: 'mastername',
    sentinels: [{
        host: '127.0.0.1',
        port: 26379
    }]
};
 
watchtower.connect(settings, function(err) {
    if(err) {
        console.log(err.message);
    } else {
        console.log('Connected to Sentinel');
    }   
});

You may now create redis clients, and use them as normal:

var client = watchtower.createClient();
 
client.get('key1', function(errdata) {
    console.log('key1: ' + data);
    client.quit();
});