how to execute redis command in shell how to execute redis command in shell shell shell

how to execute redis command in shell


Just use echo with redis-cli like this:

# Delete list of coresecho DEL cores | redis-cli# Add a new core to the list of coresecho LPUSH cores 1 | redis-cli # Wait forever for a core to become availableecho 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 keyspacedb0:keys=4,expires=0,avg_ttl=0

More options here: https://redis.io/topics/rediscli