Operating Redis using bin/redis-cli
The command-line tool bin/redis-cli
is extremely helpful for operating Redis instances. Several usages have been demonstrated in previous recipes. In this recipe, we will introduce other useful practical operations of bin/redis-cli
.
Getting ready…
You need to finish the installation of Redis Server, as we described in the Downloading and installing Redis recipe in Chapter 1, Getting Started with Redis.
How to do it...
To show how to operate Redis using redis-cli
, take the following steps:
- To run a command using
bin/redis-cli
, just append the command you want to run afterbin/redis-cli
:
$ bin/redis-cli HMSET hashkeyA field1 value1 feild2 value2 OK
- To get the raw format of a command output, use the option
--raw
:
$ bin/redis-cli --raw HGETALL hashkeyA field1 value1 feild2 value2
Note
Without the option --raw
, you will obtain the output for better human readability by default:$ bin/redis-cli hgetall hashkeyA
1) "field1"
2) "value1"
3) "feild2"
4) "value2"
- To get the CSV...