美文网首页
redis 批量执行命令

redis 批量执行命令

作者: _fishman | 来源:发表于2019-12-31 18:29 被阅读0次
    vim rename.txt
    
    rename ONLINE:CHAT:219:10003594:DEFAULT         ONLINE:COMMONCHAT:219:10003594:DEFAULT
    rename ONLINE:CHAT:219:10003573:153969          ONLINE:COMMONCHAT:219:10003573:153969
    rename ONLINE:CHAT:219:10003578:DEFAULT         ONLINE:COMMONCHAT:219:10003578:DEFAULT
    rename ONLINE:CHAT:219:10003586:200430          ONLINE:COMMONCHAT:219:10003586:200430
    rename ONLINE:CHAT:219:10003589:DEFAULT         ONLINE:COMMONCHAT:219:10003589:DEFAULT
    rename ONLINE:CHAT:219:10003590:188204          ONLINE:COMMONCHAT:219:10003590:188204
    rename ONLINE:CHAT:219:10003570:50893661        ONLINE:COMMONCHAT:219:10003570:50893661
    
    cat rename.txt | redis-cli -a password -n 12 --pipe
    

    批量删除key

    redis-cli --scan --pattern users:* | xargs redis-cli del
    

    Redis版本为4.0或者更高,还可以使用unlink命令来替代del命令:

    redis-cli --scan --pattern users:* | xargs redis-cli unlink
    

    相关文章

      网友评论

          本文标题:redis 批量执行命令

          本文链接:https://www.haomeiwen.com/subject/salioctx.html