diff --git a/base.lua b/base.lua index 523e5aa..b94c7b9 100644 --- a/base.lua +++ b/base.lua @@ -152,7 +152,7 @@ function Qless.jobs(now, state, ...) elseif state == 'depends' then return queue.depends.peek(now, offset, count) elseif state == 'recurring' then - return queue.recurring.peek(math.huge, offset, count) + return queue.recurring.peek('+inf', offset, count) else error('Jobs(): Unknown type "' .. state .. '"') end diff --git a/job.lua b/job.lua index 11b52f4..3abf54a 100644 --- a/job.lua +++ b/job.lua @@ -714,7 +714,7 @@ function QlessJob:timeout(now) self:history(now, 'timed-out') local queue = Qless.queue(queue_name) queue.locks.remove(self.jid) - queue.work.add(now, math.huge, self.jid) + queue.work.add(now, '+inf', self.jid) redis.call('hmset', QlessJob.ns .. self.jid, 'state', 'stalled', 'expires', 0) local encoded = cjson.encode({ diff --git a/queue.lua b/queue.lua index 753bbd5..1aff9f3 100644 --- a/queue.lua +++ b/queue.lua @@ -25,8 +25,11 @@ function Qless.queue(name) return redis.call('zrem', queue:prefix('work'), unpack(arg)) end end, add = function(now, priority, jid) + if priority ~= '+inf' then + priority = priority - (now / 10000000000) + end return redis.call('zadd', - queue:prefix('work'), priority - (now / 10000000000), jid) + queue:prefix('work'), priority, jid) end, score = function(jid) return redis.call('zscore', queue:prefix('work'), jid) end, length = function() @@ -38,10 +41,10 @@ function Qless.queue(name) queue.locks = { expired = function(now, offset, count) return redis.call('zrangebyscore', - queue:prefix('locks'), -math.huge, now, 'LIMIT', offset, count) + queue:prefix('locks'), '-inf', now, 'LIMIT', offset, count) end, peek = function(now, offset, count) return redis.call('zrangebyscore', queue:prefix('locks'), - now, math.huge, 'LIMIT', offset, count) + now, '+inf', 'LIMIT', offset, count) end, add = function(expires, jid) redis.call('zadd', queue:prefix('locks'), expires, jid) end, remove = function(...) @@ -49,7 +52,7 @@ function Qless.queue(name) return redis.call('zrem', queue:prefix('locks'), unpack(arg)) end end, running = function(now) - return redis.call('zcount', queue:prefix('locks'), now, math.huge) + return redis.call('zcount', queue:prefix('locks'), now, '+inf') end, length = function(now) -- If a 'now' is provided, we're interested in how many are before -- that time