Redis批量查询删除KEYS

   对腾讯云的Redis集群不支持很多指令(config get * 、flushdb、flushall、等相关指令)

redis指令限制:https://www.qcloud.com/document/product/239/4073

  没有办法,也需想出办法。。.

删除单个:del key

删除多个:redis-cli -h ip -a pass(密码)  keys 关键字 | xargs redis-cli -h ip -a pass(密码) del         #Linux下的管道符批量操作


#在redis的客户端连接处登陆删除

./redis-cli -h 10.111.0.xx  -a xx   keys '*str_ account*' | xargs ./redis-cli -h 10.111.0.xx  -a xx  del

#环境变量直接使用 ln -s  /tmp/redis/src/redis-cli  /usr/bin/

redis-cli -h 10.111.0.xx -a xx  keys '*wxsmrzResult*' | xargs redis-cli -h 10.111.0.xx  -a xx  del   

 

#在没有,指令限制的情况下,可以使用Redis的flushdb和flushall命令

删除当前数据库中的所有Key flushdb

删除所有数据库中的key       flushall

要访问 Redis 中特定的数据库

指定数据序号为0,即默认数据库 redis-cli -n 0 keys "*" | xargs redis-cli -n 0 del


注:keys 指令可以进行模糊匹配,但如果 Key 含空格,就匹配不到了

  • h?llo matches hello, hallo and hxllo           #? 匹配任意单个字符
  • h*llo matches hllo and heeeello               #* 匹配任意字符
  • h[ae]llo matches hello and hallo, but not hillo  # 或者
  • h[^e]llo matches hallo, hbllo, ... but not hello   #排除
  • h[a-b]llo matches hallo and hbllo             #

Use \ to escape special characters if you want to match them verbatim.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值