Reputation: 171
I have a Redis multicluster with 2 types of records:
4_123: 123
// and
123: 4_123
I'm removed records matching 4_*
by KEY using:
redis-cli --scan --pattern 4_* | xargs -n 1 redis-cli DEL
there also address params for an exact cluster, that is why I used xargs -n 1 ...
to avoid wrong cluster error.
Now my question is how can I delete records with VALUE matching this same pattern: '4_*'
?
Upvotes: 0
Views: 240
Reputation: 171
The only solution I've come up with so far is:
for i in $(redis-cli KEYS '?[^_]*'); do
MYVAL=$(redis-cli GET $i);
if [[ "$MYVAL" == "4_"* ]];then
redis-cli DEL $i;
fi;
done
Upvotes: 1