Details and simple examples of the Redis command

  • 2020-05-24 06:25:24
  • OfStack

Details and simple examples of the Redis command

The Redis command is used to perform operations on the redis service.

To execute commands on the redis service requires an redis client. The Redis client is in the redis installation package that we downloaded earlier.

grammar

The basic syntax of Redis client is:


$ redis-cli

The instance

The following example shows how to start the 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 execute the PING command, which is used to detect whether the redis service is started.

Execute commands on remote services

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

grammar


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

The instance

The following example demonstrates how to connect to the redis service with 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

The above is the detailed information of Redis command, if you have any questions, please leave a message or come to the community of this site to exchange and discuss, thank you for reading, hope to help you, thank you for your support to this site!


Related articles: