I want to delete all redis keys defined under namespace "datetime_filter" in ruby (maintenance task). How to do this ?
The right way to do this if you don't want to block the server is to use the SCAN command. The command will provide you an iterator returning only the keys matching your pattern if you wish (in this case it is appropriate to use the MATCH option for sure). The Ruby script will just have to iterate and delete.
So:
WHILE keys = SCAN MATCH datetime_filter*
FOREACH key in keys DEL key
Try this -
$redis.del(datetime_filter_key)
and follow following approach -
In redis, how do i remove keys?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With