May 16, 2021 Redis
The Redis command is used to perform operations on the redis service.
A redis client is required to execute commands on the redis service. The Redis client is in the redis installation package we downloaded earlier.
The basic syntax of the Redis client is:
$ redis-cli
The following example explains how to launch a redis client:
Start the redis client, open the terminal, and enter the command redis-cli. T he command connects to the local redis service.
$redis-cli redis 127.0.0.1:6379> redis 127.0.0.1:6379> PING PONG
In the above example, we connect to the local redis service and execute the PING command, which is used to detect whether the redis service is started.
If you need to execute commands on a remote redis service, we also use the redis-cli command.
$ redis-cli -h host -p port -a password
The following example shows how to connect to a host with 127.0.0.1, port 6379, and a password for mypass on the redis service.
$redis-cli -h 127.0.0.1 -p 6379 -a "mypass" redis 127.0.0.1:6379> redis 127.0.0.1:6379> PING PONG