Search code examples
node.jsredisioredis

how to check with ioredis if the a connection was established to the redis server?


I'm writing a nodejs 5.10.1 application, and i connect to a redis-server.

i'm using the ioredis nodejs module from https://github.com/luin/ioredis.

I can't seem to figure out how to check if a connection was established to the server.

the code to connect to a redis server is pretty simple:

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

the documentation states the following under Connection Events

You can also check out the Redis#status property to get the current connection status.

don't really understand what it means or how to work with it. any ideas ?


Solution

  • One of the properties of the redis object you started is the status:

    console.log(redis.status) will give you the current , in my case it says : connecting