Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 685
ufk Avatar asked Dec 10 '22 17:12

ufk


1 Answers

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

like image 75
Rabea Avatar answered Apr 19 '23 15:04

Rabea