Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joshp123/58fb4d0291a07fa554c5c13366ca2980 to your computer and use it in GitHub Desktop.
Save joshp123/58fb4d0291a07fa554c5c13366ca2980 to your computer and use it in GitHub Desktop.
One liner for deleting based on a pattern in redis. KEYS supports wildcards, delete/get/etc doesn't. No worries xargs to the rescue.
redis-cli -h <HOST> -p <PORT> KEYS "<PATTERN>" | xargs -i% redis-cli -h <HOST> -p <PORT> DEL %
#easy mmode:
redis-cli KEYS "<pattern>" | xargs -i% redis-cli GET %
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment