Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
dadeef3
commit 56bd7ad
Showing
4 changed files
with
113 additions
and
12 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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--[[ | ||
Function to add push back job considering priority in front of same prioritized jobs. | ||
]] | ||
local function pushBackJobWithPriority(priorityKey, priority, targetKey, jobId) | ||
rcall("ZADD", priorityKey, priority, jobId) | ||
local count = rcall("ZCOUNT", priorityKey, 0, priority-1) | ||
|
||
local len = rcall("LLEN", targetKey) | ||
local id = rcall("LINDEX", targetKey, len - count) | ||
rcall("ZADD", priorityKey, priority, jobId) | ||
|
||
if id then | ||
rcall("LINSERT", targetKey, "BEFORE", id, jobId) | ||
else | ||
rcall("RPUSH", targetKey, jobId) | ||
end | ||
end |
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
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