Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Redis command


May 16, 2021 Redis


Table of contents


Redis command

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.

Grammar

The basic syntax of the Redis client is:

$ redis-cli

Instance

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.


Execute commands on the remote service

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

Grammar

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

Instance

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