Skip to content

Instantly share code, notes, and snippets.

@x0bandeira
Created June 10, 2015 21:58
Show Gist options
  • Save x0bandeira/665354f4fb30b8f60bae to your computer and use it in GitHub Desktop.
Save x0bandeira/665354f4fb30b8f60bae to your computer and use it in GitHub Desktop.
Shuffle resque queue
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