Redis Commands
Redis commands are used to perform operations on the redis service.
To execute commands on the redis service, a redis client is required. The redis client is included in the redis installation package we downloaded earlier.
Syntax
The basic syntax of the redis client is:
$ redis-cli
Example
The following example shows how to start the redis client:
Start the redis server, open a terminal and enter the command redis-cli, which connects to the local redis service.
$ redis-cli
redis 127.0.0.1:6379>
redis 127.0.0.1:6379> PING
PONG
In the example above, we connect to the local redis service and execute PING command, which is used to check whether the redis service is running.
Executing commands on a remote service
If you need to execute commands on a remote redis service, we also use redis-cli command.
Syntax
$ redis-cli -h host -p port -a password
Example
The following example demonstrates how to connect to the redis service at host 127.0.0.1, port 6379, with password 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