Skip to content

Commit

Permalink
Merge pull request #1 from dccunha/dc/fix/using_scan_at_cleanup
Browse files Browse the repository at this point in the history
Using SCAN instead of KEYS at remove_queue
  • Loading branch information
pboling authored Jun 4, 2019
2 parents 3636a72 + 0b64d02 commit a7d8a01
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/resque/unique_in_queue/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ def destroy(queue, klass, *args)
end

def cleanup(queue)
keys = redis.keys("#{Resque::UniqueInQueue.configuration&.unique_in_queue_key_base}:queue:#{queue}:job:*")
redis.del(*keys) if keys.any?
pattern = "#{Resque::UniqueInQueue.configuration&.unique_in_queue_key_base}:queue:#{queue}:job:*"
keys = redis.scan_each(match: pattern, count: 1_000_000).to_a
redis.del(keys) if keys.any?
end

private
Expand Down

0 comments on commit a7d8a01

Please sign in to comment.