This article is a mirror article of machine translation, please click here to jump to the original article.

View: 11415|Reply: 0

[Redis] redis wildcards to delete keys in bulk

[Copy link]
Posted on 8/12/2019 5:12:14 PM | | |
In Redis, the DEL command supports multiple keys as parameters to delete, but it does not support wildcards, and keys cannot be deleted in batches through wildcards.However, we can do this with the help of Linux pipelines and xargs directives

For example, to remove all keys that start with user, you can do this way:

[root@dev_opayredis src]# redis-cli keys "user*"
1) "user1"
2) "user2"
[root@dev_opayredis src]# redis-cli keys "user*" | xargs redis-cli del
(integer) 2

Delete successful
Note: The command is only available for Linux servers, not Windows servers.

There is a bug in the redis cache, which causes too much dirty data to need to be cleaned. However, the del of redis does not support batch deletion of wildcards by default, and we use linux commands to implement batch deletion

  • -h redis host address
  • -a password
  • -n Specify the database number
  • keys wildcard key



Delete the specified line data for the specified wildcard key







Previous:Buy car USB flash drive 3T content
Next:The 75th day of unemployment in Shenzhen
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com