all: I want to operate redis in my shell,my locate redis ip:127.0.0.1 port:6379,i want to insert data to the redis in my shell,but i don't know how to operate redis in my own shell,is there any redis command like mysql -e to execute in the shell directly.
The Redis command line interface ( redis-cli ) is a terminal program used to send commands to and read replies from the Redis server.
How to Check Redis installed version. Open terminal, Type redis-server --version or redis-server -v in the command line. You can also check with the redis-cli command.
Please note that Konstantin’s answer is better.
Just use echo
with redis-cli
like this:
# 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
It's is simpler to call commands directly, without pipelines:
> redis-cli -n 0 LPUSH mylist "hello"
(integer) 1
Be shure that you pass -n
option, it's like mysql use <database>
statement, it's set used database (first index is zero). When you run command from cli redis don't uses default database. To get information about databases which has some keys use command:
> INFO keyspace
db0:keys=4,expires=0,avg_ttl=0
More options here: https://redis.io/topics/rediscli
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With