Skip to content

Commit

Permalink
Major Change! Priority is no longer like 'nice'-ness -- a higher numb…
Browse files Browse the repository at this point in the history
…er means it gets popped earlier.
  • Loading branch information
Dan Lecocq committed May 18, 2012
1 parent ba743e1 commit c4c875a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion complete.lua
Expand Up @@ -153,7 +153,7 @@ if nextq then
redis.call('hset', 'ql:j:' .. jid, 'state', 'depends') redis.call('hset', 'ql:j:' .. jid, 'state', 'depends')
return 'depends' return 'depends'
else else
redis.call('zadd', 'ql:q:' .. nextq .. '-work', priority + (now / 10000000000), jid) redis.call('zadd', 'ql:q:' .. nextq .. '-work', priority - (now / 10000000000), jid)
return 'waiting' return 'waiting'
end end
end end
Expand Down
4 changes: 2 additions & 2 deletions peek.lua
Expand Up @@ -73,7 +73,7 @@ if #keys < count then
-- Now, if a delay was provided, and if it's in the future, -- Now, if a delay was provided, and if it's in the future,
-- then we'll have to schedule it. Otherwise, we're just -- then we'll have to schedule it. Otherwise, we're just
-- going to add it to the work queue. -- going to add it to the work queue.
redis.call('zadd', key .. '-work', priority + (now / 10000000000), jid .. '-' .. count) redis.call('zadd', key .. '-work', priority - (now / 10000000000), jid .. '-' .. count)


redis.call('zincrby', key .. '-recur', interval, jid) redis.call('zincrby', key .. '-recur', interval, jid)
end end
Expand Down Expand Up @@ -112,7 +112,7 @@ if #keys < count then


-- And now we should get up to the maximum number of requested -- And now we should get up to the maximum number of requested
-- work items from the work queue. -- work items from the work queue.
for index, jid in ipairs(redis.call('zrange', key .. '-work', 0, (count - #keys) - 1)) do for index, jid in ipairs(redis.call('zrevrange', key .. '-work', 0, (count - #keys) - 1)) do
table.insert(keys, jid) table.insert(keys, jid)
end end
end end
Expand Down
4 changes: 2 additions & 2 deletions pop.lua
Expand Up @@ -136,7 +136,7 @@ if #keys < count then
-- Now, if a delay was provided, and if it's in the future, -- Now, if a delay was provided, and if it's in the future,
-- then we'll have to schedule it. Otherwise, we're just -- then we'll have to schedule it. Otherwise, we're just
-- going to add it to the work queue. -- going to add it to the work queue.
redis.call('zadd', key .. '-work', priority + (now / 10000000000), jid .. '-' .. count) redis.call('zadd', key .. '-work', priority - (now / 10000000000), jid .. '-' .. count)


redis.call('zincrby', key .. '-recur', interval, jid) redis.call('zincrby', key .. '-recur', interval, jid)
end end
Expand Down Expand Up @@ -170,7 +170,7 @@ if #keys < count then


-- And now we should get up to the maximum number of requested -- And now we should get up to the maximum number of requested
-- work items from the work queue. -- work items from the work queue.
for index, jid in ipairs(redis.call('zrange', key .. '-work', 0, (count - #keys) - 1)) do for index, jid in ipairs(redis.call('zrevrange', key .. '-work', 0, (count - #keys) - 1)) do
table.insert(keys, jid) table.insert(keys, jid)
end end
end end
Expand Down
2 changes: 1 addition & 1 deletion put.lua
Expand Up @@ -138,7 +138,7 @@ else
redis.call('zadd', 'ql:q:' .. queue .. '-depends', now, jid) redis.call('zadd', 'ql:q:' .. queue .. '-depends', now, jid)
redis.call('hset', 'ql:j:' .. jid, 'state', 'depends') redis.call('hset', 'ql:j:' .. jid, 'state', 'depends')
else else
redis.call('zadd', 'ql:q:' .. queue .. '-work', priority + (now / 10000000000), jid) redis.call('zadd', 'ql:q:' .. queue .. '-work', priority - (now / 10000000000), jid)
end end
end end


Expand Down
2 changes: 1 addition & 1 deletion retry.lua
Expand Up @@ -65,7 +65,7 @@ else
redis.call('zadd', 'ql:q:' .. queue .. '-scheduled', now + delay, jid) redis.call('zadd', 'ql:q:' .. queue .. '-scheduled', now + delay, jid)
redis.call('hset', 'ql:j:' .. jid, 'state', 'scheduled') redis.call('hset', 'ql:j:' .. jid, 'state', 'scheduled')
else else
redis.call('zadd', 'ql:q:' .. queue .. '-work', priority + (now / 10000000000), jid) redis.call('zadd', 'ql:q:' .. queue .. '-work', priority - (now / 10000000000), jid)
redis.call('hset', 'ql:j:' .. jid, 'state', 'waiting') redis.call('hset', 'ql:j:' .. jid, 'state', 'waiting')
end end
end end
Expand Down

0 comments on commit c4c875a

Please sign in to comment.