Created
June 4, 2012 19:05
-
-
Save mattweyant/2870203 to your computer and use it in GitHub Desktop.
Delete all keys from Redis matching a regular expression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All credit: http://stackoverflow.com/questions/4006324/how-to-atomically-delete-keys-matching-a-pattern-with-redis | |
redis-cli [options] KEYS "prefix:*" | xargs redis-cli [options] DEL |
If your keys have any escape characters you need to change the xargs delimiter:
redis-cli --scan --pattern "horizon:failed:*" | xargs -n 1 -d '\n' redis-cli DEL
that's my case, it worked - thanks a lot @jessecurry
How do I achieve the same using the redis pypi package ? Right now I'm using r.delete(*r.keys("someKey_*"))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, it did work.