redis 批量执行命令

2019-12-31  本文已影响0人  _fishman
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
上一篇下一篇

猜你喜欢

热点阅读