Quantcast
Channel: How to delete keys matching a pattern in Redis Cluster - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Jason Hoetger for How to delete keys matching a pattern in Redis Cluster

$
0
0

Building on for_stack's answer, you can speed up mass deletion quite a bit using redis-cli --pipe, and reduce the performance impact with UNLINK instead of DEL if you're using redis 4 or higher.

redis-cli --scan --pattern "foo*" | xargs -L 1 echo UNLINK | redis-cli --pipe

Output will look something like this:

All data transferred. Waiting for the last reply...Last reply received from server.errors: 0, replies: 107003

You do still need to run this against every master node in your cluster. If you have a large number of nodes, it's probably possible to automate the process further by parsing the output of CLUSTER NODES.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>