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