Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check whether the Redis server is running

Tags:

php

fuelphp

How to check whether the Redis server is running?

If it's not running, I want to fallback to using the database.

I'm using the FuelPHP framework, so I'm open to a solution based on this, or just standard PHP.

like image 799
Chris Harrison Avatar asked Mar 26 '12 04:03

Chris Harrison


People also ask

How do I know if Redis server is running?

To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command. In the above example, we connect to Redis server running on the local machine and execute a command PING, that checks whether the server is running or not.

How do I know if Redis is connected?

If you want to test redis connection once at startup, use the ping() command. The command ping() checks the connection and if invalid will raise an exception. Note - the connection may still fail after you perform the test so this is not going to cover up later timeout exceptions.

How do I know if Redis Cache is working?

In order to check if Redis is really working. Monitor REDIS realtime. The reload your application and see if something is going in your monitor. You should be able to see some SET happening.


1 Answers

You can use command line to determine if redis is running:

redis-cli ping 

you should get back

PONG 

that indicates redis is up and running.

like image 129
Amir Hassan Azimi Avatar answered Sep 25 '22 09:09

Amir Hassan Azimi