Redis Command
Redis commands are 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 that we downloaded earlier. Grammar
The basic syntax for a REDIS client is:
$ redis-cli
Example
The following examples explain how to start a Redis client:
Start the Redis client, open the terminal and enter the command redis-cli. This 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 perform a PING command that detects whether the Redis service is started. to execute a command on a remote service
If you need to execute commands on the remote Redis service, we also use the redis-cli command. Grammar
$ redis-cli-h host-p port-a Password
Example
The following example shows how to connect to a Redis service with a host of 127.0.0.1, a port of 6379, and a password of mypass.
$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