Easy Tutorial
❮ Server Cluster Slots Redis Install ❯

Redis Commands

Redis commands are used to perform operations on the redis service.

To execute commands on the redis service, you need a redis client. The redis client is included in the redis installation package we downloaded earlier.

Syntax

The basic syntax for the Redis client is:

$ redis-cli

Example

The following example explains how to start the redis client:

Start the redis server, open the terminal, and enter the command redis-cli, which will connect 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 connected to the local redis service and executed the PING command, which is used to check if the redis service is running.


Executing Commands on a Remote Server

If you need to execute commands on a remote redis service, we also use the redis-cli command.

Syntax

$ redis-cli -h host -p port -a password

Example

The following example demonstrates how to connect to a redis service with the host 127.0.0.1, port 6379, and 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
❮ Server Cluster Slots Redis Install ❯