all:我想在我的shell中操作redis,我的定位redis ip:127.0.0.1端口:6379,我想在我的shell中插入数据到redis中,但我不知道如何在我自己的shell中操作redis,有没有像mysql -e这样的redis命令可以直接在shell中执行。
发布于 2015-07-08 17:17:00
只需将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发布于 2017-09-20 17:54:03
直接调用命令会更简单,不需要管道:
> 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
https://stackoverflow.com/questions/31287826
复制相似问题