之前有分析过 bull 的 priority 和 lifo 是如何实现的
当优先级为0时,lifo 为 false 意味着使用 LPUSH,lifo 为 true 意味着使用 RPUSH
当优先级不为0时,会使用 priority zset 里的优先级排序来计算 job 应该插入哪个位置
这存在一个显而易见的问题,就是 lifo 为 true 的 job 不会放在 priority zset 里
所以 lifo 为 true 的 job 会打乱优先级的排序
-- Standard or priority add
local priority = tonumber(ARGV[9])
if priority == 0 then
-- LIFO or FIFO
rcall(ARGV[10], target, jobId) -- push to wait or paused list
else
-- Priority add
rcall("ZADD", KEYS[6], priority, jobId) -- add to priority zset
local count = rcall("ZCOUNT", KEYS[6], 0, priority)
local len = rcall("LLEN", target)
local id = rcall("LINDEX", target, len -