6
votes

I'm using ioredis module.

var Redis = require('ioredis');
var redis = new Redis();

On doing new Redis() a connection is established to the redis server, how can I find out when this connection established? some callback perhaps?

1

1 Answers

8
votes

You can listen for the connect event:

redis.on('connect', function () { /* do something */ });

You can also use the connect(callback) method:

redis.connect(function () { /* Do your stuff */ });

The latter also returns a promise if you prefer that.