Skip to content

Commit

Permalink
Fix Nil problem and add readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Aflalo committed Apr 24, 2017
1 parent 12212f0 commit ca1f786
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Illuminate/Queue/LuaScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public static function pop()
-- Pop the first job off of the queue...
local job = redis.call('lpop', KEYS[1])
local reserved = false
local timeout = ARGV[2]
local timeout = tonumber(ARGV[2])
local score = tonumber(ARGV[1])
if(job ~= false) then
-- Increment the attempt count and place job on the reserved queue...
Expand All @@ -44,11 +45,12 @@ public static function pop()
-- Retrieve the timeout of the job if set, per documentation it has precedence
-- on the one of the queue
if(reserved['timeout'] ~= nil) then
timeout = reserved['timeout']
local timeoutJob = tonumber(reserved['timeout'])
if(timeoutJob ~= nil) then
timeout = timeoutJob;
end
local score = tonumber(ARGV[1]) + tonumber(timeout)
score = score + timeout
reserved = cjson.encode(reserved)
redis.call('zadd', KEYS[2], score, reserved)
Expand Down

0 comments on commit ca1f786

Please sign in to comment.