How to execute a redis command in a shell

everything: I want to work redis in my shell, my lockout is redis ip: 127.0.0.1 port: 6379, I want to insert data into redis in my shell, but I don’t know how to work redis in my own shell, is there any redis command , such as mysql -e, execute directly in the shell.

+4
source share
2 answers

Just use echowith redis-clias follows:

# Delete list of cores
echo DEL cores | redis-cli

# Add a new core to the list of cores
echo LPUSH cores 1 | redis-cli 

# Wait forever for a core to become available
echo BLPOP cores 0 | redis-cli
+10
source

It’s less easy to access commands without pipelines:

> redis-cli -n 0 LPUSH mylist "hello"
(integer) 1

, -n, mysql use <database>, ( ). cli redis . , :

> INFO keyspace
db0:keys=4,expires=0,avg_ttl=0

: https://redis.io/topics/rediscli

+1

All Articles