Created
February 4, 2015 02:44
-
-
Save pguelpa/5c13fa5949dd995c042d to your computer and use it in GitHub Desktop.
Ruby / Redis + iterate through keys
This file contains 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
iterator = nil | |
keys = [] | |
while iterator != '0' | |
iterator, list = Redis.current.scan(iterator || 0, count: 1000) | |
keys += list.map { |l| l.split(':') } | |
puts "Found another #{list.length} keys, iterator at #{iterator}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just use :)
https://github.com/redis/redis-rb/blob/448322f0faff320eacec82682314edefb1b12036/lib/redis.rb#L2655