perf(scripts): remove token after moving to wait or delayed (#2731)

This commit is contained in:
Rogger Valverde
2024-05-10 07:51:07 -06:00
committed by GitHub
parent 6d84156966
commit 7ee8f7430a
3 changed files with 13 additions and 14 deletions
@@ -5,6 +5,7 @@
KEYS[1] active key
KEYS[2] delayed key
KEYS[3] job key
KEYS[4] stalled key
ARGV[1] delayedTimestamp
ARGV[2] the id of the job
@@ -21,14 +22,13 @@
local rcall = redis.call
if rcall("EXISTS", KEYS[3]) == 1 then
local lockKey
local lock
-- Check for job lock
if ARGV[3] ~= "0" then
lockKey = KEYS[3] .. ':lock'
lock = rcall("GET", lockKey)
if lock ~= ARGV[3] then
local lockKey = KEYS[3] .. ':lock'
if rcall("GET", lockKey) == ARGV[3] then
rcall("DEL", lockKey)
rcall("SREM", KEYS[4], ARGV[2])
else
return -2
end
end
@@ -38,10 +38,6 @@ if rcall("EXISTS", KEYS[3]) == 1 then
rcall("PUBLISH", KEYS[2], (score / 0x1000))
rcall("LREM", KEYS[1], 0, ARGV[2])
if lock then
rcall("DEL", lockKey)
end
return 0
else
return -1
@@ -7,6 +7,7 @@
KEYS[3] jobId
KEYS[4] 'meta-paused'
KEYS[5] 'paused'
KEYS[6] stalled key
ARGV[1] pushCmd
ARGV[2] jobId
@@ -26,8 +27,10 @@ if rcall("EXISTS", KEYS[3]) == 1 then
-- Check for job lock
if ARGV[3] ~= "0" then
local lockKey = KEYS[3] .. ':lock'
local lock = rcall("GET", lockKey)
if lock ~= ARGV[3] then
if rcall("GET", lockKey) == ARGV[3] then
rcall("DEL", lockKey)
rcall("SREM", KEYS[6], ARGV[2])
else
return -2
end
end
+2 -2
View File
@@ -307,7 +307,7 @@ const scripts = {
timestamp = timestamp * 0x1000 + (jobId & 0xfff);
}
const keys = _.map(['active', 'delayed', jobId], name => {
const keys = _.map(['active', 'delayed', jobId, 'stalled'], name => {
return queue.toKey(name);
});
return keys.concat([
@@ -478,7 +478,7 @@ const scripts = {
const jobId = job.id;
const keys = _.map(
['active', 'wait', jobId, 'meta-paused', 'paused'],
['active', 'wait', jobId, 'meta-paused', 'paused', 'stalled'],
name => {
return queue.toKey(name);
}