Created
June 10, 2015 21:58
-
-
Save x0bandeira/665354f4fb30b8f60bae to your computer and use it in GitHub Desktop.
Shuffle resque queue
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
redis = Redis.current | |
key = "resque:queue:bulk" | |
total = redis.llen(key) | |
batch = [] | |
total.times do |i| | |
entry = redis.lpop(key) | |
batch << entry | |
if batch.size == 1000 | |
puts "re-inserting batch..." | |
redis.rpush key, batch.shuffle | |
batch = [] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment