`keepLastIfActive` 的性能问题以及建议的简单解决方案
作者: Eric24创建于 2026年8月23日更新于 2026年9月11日
src/commands/includes/storeDeduplicatedNextJob.lua,在master上的第 12 至 15 行:
if deduplicationOpts['keepLastIfActive'] and currentDeduplicatedJobId then
local activeKey = prefix .. "active"
local activeItems = rcall('LRANGE', activeKey, 0, -1)
if checkItemInList(activeItems, currentDeduplicatedJobId) then使用src/commands/includes/checkItemInList.lua:
local function checkItemInList(list, item)
for _, v in pairs(list) do
if v == item then
return 1
end
end
return nil
endstoreDeduplicatedNextJob 来自 deduplicateJob (替换路径) 和 deduplicateJobWithoutReplace,即来自 addStandardJob、addDelayedJob、addPrioritizedJob 和 addParentJob。为了明确范围:keepLastIfActive 保护是函数中的第一个条件,因此不启用此选项的用户不付费。这完全是一种自愿成本 - 但它是一个成本,正好在功能最有用的地方增长。
内容来源: taskforcesh/bullmq