Files
simple-mail-cleaner/backend/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua
2026-01-22 15:49:12 +01:00

24 lines
634 B
Lua

--[[
Function to remove deduplication key if needed
when a job is moved to completed or failed states.
]]
local function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,
deduplicationId, jobId)
if deduplicationId then
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
local pttl = rcall("PTTL", deduplicationKey)
if pttl == 0 then
return rcall("DEL", deduplicationKey)
end
if pttl == -1 then
local currentJobId = rcall('GET', deduplicationKey)
if currentJobId and currentJobId == jobId then
return rcall("DEL", deduplicationKey)
end
end
end
end