Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stevepop/bf62d1d6833d774140e4a058042d408c to your computer and use it in GitHub Desktop.
Save stevepop/bf62d1d6833d774140e4a058042d408c to your computer and use it in GitHub Desktop.
Remove all the keys from redis matching a pattern
--Starting with redis 2.6.0, you can run lua scripts
EVAL "return redis.call('del', unpack(redis.call('keys', ARGV[1])))" 0 prefix:*
--For big number of keys
EVAL "local keys = redis.call('keys', ARGV[1]) \n for i=1,#keys,5000 do \n redis.call('del', unpack(keys, i, math.min(i+4999, #keys))) \n end \n return keys" 0 prefix:*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment