public function putJob($queue, $id, $delay = 0, $priority = self::PRIORITY_LOW)
{
$delay = intval($delay);
$keyReady = $this->getKeyReady($queue);
$keyDelayed = $this->getKeyDelayed($queue);
$redisJobNamespace = $this->getRedisJobNamespace();
$result = $this->getRedis()->transaction(function ($tx) use($queue, $id, $delay, $keyDelayed, $priority, $keyReady, $redisJobNamespace) {
/** @var $tx \Predis\Client */
$payload = self::buildPayload($queue, $delay ? self::STATE_DELAYED : self::STATE_READY);
$tx->hset($redisJobNamespace, $id, $payload);
if ($delay <= 0) {
if (self::PRIORITY_HIGH === $priority) {
$tx->lpush($keyReady, $id);
} else {
$tx->rpush($keyReady, $id);
}
} else {
$tx->zadd($keyDelayed, $this->getTime() + $delay, $id);
}
});
return !in_array(false, $result);
}