Cronario\Queue::reserveJob PHP Méthode

reserveJob() public méthode

public reserveJob ( $queue, null $timeout = null ) : null | string
$queue
$timeout null
Résultat null | string
    public function reserveJob($queue, $timeout = null)
    {
        $this->migrate($queue);
        $keyReady = $this->getKeyReady($queue);
        $keyReserved = $this->getKeyReserved($queue);
        if ($this->isStop($queue)) {
            return null;
        }
        if ($timeout > 0) {
            $id = $this->getRedis()->blpop($keyReady, $timeout);
            /**
             *  return [
             *      '0' => queueName ,
             *      '1' => jobId
             *  ]
             */
            $id = is_array($id) ? $id[1] : null;
        } else {
            $id = $this->getRedis()->lpop($keyReady);
        }
        if (!is_null($id)) {
            $payload = self::buildPayload($queue, self::STATE_RESERVED);
            $this->getRedis()->hset($this->getRedisJobNamespace(), $id, $payload);
            $this->getRedis()->zadd($keyReserved, $this->getTime(), $id);
            return $id;
        }
        return null;
    }