Executing batches of commands using redis cli

后端 未结 4 2014
攒了一身酷
攒了一身酷 2020-12-13 03:10

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


        
相关标签:
4条回答
  • 2020-12-13 03:51

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

    echo "DEL 9012012\nDEL 1212" | redis-cli
    
    0 讨论(0)
  • 2020-12-13 04:04

    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?

    0 讨论(0)
  • 2020-12-13 04:07

    I know this is an old old thread, but adding this since it seems missed out among other answers, and one that works well for me.

    Using heredoc works well here, if you don't want to use echo or explicitly add \n or create a new file -

    redis-cli <<EOF
    select 15
    get a
    EOF
    
    0 讨论(0)
  • 2020-12-13 04:10

    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

    0 讨论(0)
提交回复
热议问题