-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(queue): add getCountsPerPriority method (#2746)
- Loading branch information
1 parent
66ffd9d
commit 0376dcc
Showing
7 changed files
with
125 additions
and
35 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,25 @@ | ||
--[[ | ||
Get counts per provided states | ||
Input: | ||
KEYS[1] wait key | ||
KEYS[2] priority key | ||
ARGV[1...] priorities | ||
]] | ||
local rcall = redis.call | ||
local results = {} | ||
local waitKey = KEYS[1] | ||
local prioritizedKey = KEYS[2] | ||
|
||
for i = 1, #ARGV do | ||
local priority = tonumber(ARGV[i]) | ||
if priority == 0 then | ||
results[#results+1] = rcall("LLEN", waitKey) - rcall("ZCARD", prioritizedKey) | ||
else | ||
results[#results+1] = rcall("ZCOUNT", prioritizedKey, | ||
priority, priority) | ||
end | ||
end | ||
|
||
return results |
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
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
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