Executing batches of commands using redis cli

2019-03-08 22:20发布

I have a long text file of redis commands that I need to execute using the redis command line interface:

e.g.

DEL 9012012
DEL 1212
DEL 12214314

etc.

I can't seem to figure out a way to enter the commands faster than one at a time. There are several hundred thousands lines, so I don't want to just pile them all into one DEL command, they also don't need to all run at once.

标签: redis
3条回答
Emotional °昔
2楼-- · 2019-03-08 23:01

If you don't want to make a file, use echo and \n

echo "DEL 9012012\nDEL 1212" | redis-cli
查看更多
做自己的国王
3楼-- · 2019-03-08 23:11

the following code works for me with redis 2.4.7 on mac

./redis-cli < temp.redisCmds

Does that satisfy your requirements? Or are you looking to see if there's a way to programmatically do it faster?

查看更多
地球回转人心会变
4楼-- · 2019-03-08 23:26

The redis-cli --pipe can be used for mass-insertion. It is available since 2.6-RC4 and in Redis 2.4.14. For example:

cat data.txt | redis-cli --pipe

More info in: http://redis.io/topics/mass-insert

查看更多
登录 后发表回答