Redis Bulk Delete keys

Source: Internet
Author: User
The Del in Redis can delete a single key, for the need to delete key in bulk we can use Linux Xargs
The code is as follows:
/USR/LOCAL/BIN/REDIS-CLI Keys xxxxxx | Xargs redis-cli del
If REDIS-CLI is not set as a system variable, you need to specify the full path of REDIS-CLI
Example:/opt/redis/redis-cli Keys "*" | Xargs/opt/redis/redis-cli del

If you want to specify a Redis database access password, use the following command:
The code is as follows:
redis-cli-a Password Keys "*" | Xargs redis-cli-a Password del
If you want to access a specific database in Redis, use the following command:
The code is as follows:
The following command specifies that the data sequence number is 0, which is the default database
Redis-cli-n 0 Keys "*" | Xargs redis-cli-n 0 del
Remove all keys
To remove all keys, you can use the Redis flushdb and Flushall commands:
The code is as follows:
Delete all keys in the current database
Flushdb
Remove key from all databases
Flushall

From for notes (Wiz)

Redis Bulk Delete keys

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.