码迷,mamicode.com
首页 > 其他好文 > 详细

redis批量删除key

时间:2020-11-23 12:37:45      阅读:7      评论:0      收藏:0      [点我收藏+]

标签:xargs   local   color   word   style   bin   end   redis   RKE   

 

生成key

192.168.1.50:6379> set name1 hxl
OK
192.168.1.50:6379> set name2 hxl02
OK
192.168.1.50:6379> set name3 hxl03
OK
192.168.1.50:6379> get name1
"hxl"
192.168.1.50:6379> get name2
"hxl02"
192.168.1.50:6379> get name3
"hxl03"
192.168.1.50:6379> exit

批量删除
[root@cdc-henan-cdhworker02 /]# /usr/local/redis/bin/redis-cli -h 192.168.1.50 -p 6379 -a test123 KEYS "*name*"|xargs /usr/local/redis/bin/redis-cli -h 192.168.1.50 -a test123 del
Warning: Using a password with ‘-a‘ or ‘-u‘ option on the command line interface may not be safe.
Warning: Using a password with ‘-a‘ or ‘-u‘ option on the command line interface may not be safe.
(integer) 3

检查是否已经删除


[root@cdc-henan-cdhworker02 /]# /usr/local/redis/bin/redis-cli -h 192.168.1.50 -p 6379 -a test123
Warning: Using a password with ‘-a‘ or ‘-u‘ option on the command line interface may not be safe.
192.168.1.50:6379> get name1
(nil)
192.168.1.50:6379> get name2
(nil)
192.168.1.50:6379> get name3
(nil)
192.168.1.50:6379>

 

-- The End --

redis批量删除key

标签:xargs   local   color   word   style   bin   end   redis   RKE   

原文地址:https://www.cnblogs.com/hxlasky/p/14004685.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!