Created
July 18, 2016 10:21
-
-
Save mahemoff/c3abf31d5eeda2b2ac751dccd5182cb9 to your computer and use it in GitHub Desktop.
Monkey-patch redis namespace to delete all keys
This file contains hidden or 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
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