Retrieve a list of all keys stored in Redis (Ruby)
If you have any substantial amount of records in your db, kernel will kill your redis.keys
because it will be taking too much RAM.
What you want is extracting keys in batches. redis-rb has a wonderful method for this (not present in redis itself):
redis.scan_each(match: 'user:*') do |resume_key_name| resume_key_name #=> "user:12" end
If you want all the keys, just don't use the match
option.
redis.keys
this will return the result in array form.
more info : http://www.rubydoc.info/github/ezmobius/redis-rb/Redis