title: How to create a Redis connection with Master and Slave
body: <p>I am trying to do a Redis connection, I have a "master" port and two slaves. I want to do this with a Sentinel. </p>
  
  <p>My actually code to connect redis is actually deprecated, I think so.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>var redis = require('redis');
  var client = redis.createClient(config.redis_port, config.redis_host,
  {no_ready_check: true});
  
  if (config.redis_password != null) {
    client.auth(config.redis_password, function (err) {
      if (err) throw err;
    });
  }
  
  client.on('connect', function(err, res) {
    logger.info('Connected to Redis ' + process.pid);
    redisIsReady = true;
  });
  
  client.on('error', function(err) {
    logger.error('Error connecting to Redis ' + process.pid);
    redisIsReady = false;
  });
  
  client.get(objectRequest.customerId, function(err, reply) {
      if (reply != null &amp;&amp; reply &gt;= config.max_requests) {
        var json = JSON.stringify({errorCode: validationErrors.TOO_MANY_REQUEST,
          description: errorMessage[validationErrors.TOO_MANY_REQUEST]});
        res.setHeader('Retry-After', config.retry_after);
        res.setHeader('Content-Type', 'application/json');
        res.setHeader('Content-Length', json.length);
        res.writeHead(429);
        res.write(json);
        return res.end();
      }
      // Set a value with an expiration
      client.incr(objectRequest.customerId);
      client.expire(objectRequest.customerId, config.retry_after);
  });
  </code></pre>
  
  <p>I am reading on others posts and I think that maybe will be cool do it with ioredis. But I dont know much about Redis...</p>
  
  <p>I want to do a connection to redis and if the master is down, this automatically connect to slave.</p>
  
  <p>I hope you help me,</p>
  
  <p>Roth.</p>