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

Answer by Archimedes Trajano for How to delete keys matching a pattern in Redis Cluster

$
0
0

redis-cli provides a -c option to follow MOVED redirects. However, it should be deleted one at a time because you cannot guarantee two keys will be in the same node.

redis-cli -h myredis.internal --scan --pattern 'mycachekey::*' | \  xargs -L 1 -d'\n' redis-cli -h myredis.internal -c del

The first part provides a list of keys --scan prevents Redis from locking. xargs -L 1 runs the command for one entry at a time. -d'\n' disables the processing of quotes so you can have quoted strings like "SimpleKey[hello world]" be passed to the command otherwise the spaces will make it have two keys.


Viewing all articles
Browse latest Browse all 4

Trending Articles



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