Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created July 18, 2016 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahemoff/c3abf31d5eeda2b2ac751dccd5182cb9 to your computer and use it in GitHub Desktop.
Save mahemoff/c3abf31d5eeda2b2ac751dccd5182cb9 to your computer and use it in GitHub Desktop.
Monkey-patch redis namespace to delete all keys
class Redis::Namespace
def delete_all_keys
keys = self.keys '*'
self.del keys if keys.present?
end
end
funky_redis = Redis::Namespace.new('funky', redis: Redis.new(url: '...'))
funky_redis.set 'count', 10 # makes funky:10 entry
funky_redis.delete_all_keys # deletes funky:10 entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment