all:我想在我的shell中运行redis,我的定位redis ip:127.0.0.1 port:6379,我想在我的shell中将数据插入redis,但我不知道如何在我自己的shell中运行redis,是否有像mysql -e这样的redis命令直接在shell中执行.
Mar*_*ell 14
只要使用echo具有redis-cli这样的:
# 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
Run Code Online (Sandbox Code Playgroud)
直接调用命令更简单,无需管道:
> redis-cli -n 0 LPUSH mylist "hello"
(integer) 1
Run Code Online (Sandbox Code Playgroud)
确保您传递-n选项,它就像 mysqluse <database>语句,它设置了使用的数据库(第一个索引为零)。当您从 cli redis 运行命令时,不使用默认数据库。要获取有关具有某些键的数据库的信息,请使用命令:
> INFO keyspace
db0:keys=4,expires=0,avg_ttl=0
Run Code Online (Sandbox Code Playgroud)
更多选项:https : //redis.io/topics/rediscli