Skip to content

Commit

Permalink
fix(perf): break out all way on found
Browse files Browse the repository at this point in the history
  • Loading branch information
mhenrixon committed Feb 17, 2024
1 parent 97a6f38 commit d9c0115
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/sidekiq_unique_jobs/lua/shared/_delete_from_queue.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
local function delete_from_queue(queue, digest)
local per = 50
local total = redis.call("LLEN", queue)
local index = 0
local per = 50
local total = redis.call("LLEN", queue)
local result = nil

while (index < total) do
local items = redis.call("LRANGE", queue, index, index + per -1)
for index = 0, total, per do
local items = redis.call("LRANGE", queue, index, index + per - 1)
if #items == 0 then
break
end
for _, item in pairs(items) do
for _, item in ipairs(items) do
if string.find(item, digest) then
redis.call("LREM", queue, 1, item)
result = item
break
end
end
index = index + per
if result then break end
end

return result
end

0 comments on commit d9c0115

Please sign in to comment.