-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(perf): break out all way on found
- Loading branch information
Showing
1 changed file
with
7 additions
and
7 deletions.
There are no files selected for viewing
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
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 |