Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ping command in ioredis-Node JS

Is there any way to check weather redis is available or terminated due to some issues before I am setting or getting a key ? How can I achieve that?

I am using ioredis module.

like image 670
Kishore Indraganti Avatar asked Mar 13 '23 12:03

Kishore Indraganti


1 Answers

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


 var test = redis.ping(function (err, result) {
     console.log(result);
 });

The result should be the word PONG if no paramters are passed and Redis is working.

PONG: This command is often used to test if a connection is still alive, or to measure latency.

like image 108
Rabea Avatar answered Mar 24 '23 19:03

Rabea