/** * 获取一个任务 * * @return bool|Caster */ private function getReadyJob() { $keyChip = $this->queue->name . ':' . Job::JOBS_TAB . ':' . $this->tube . ':'; $timePort = Util::now(); $this->expireActivate($keyChip, $timePort); if (!($id = $this->pop($keyChip . Job::STATE_READY, $timePort))) { return false; } if (!($job = Caster::reload($id))) { return false; } $this->client->hIncrBy($this->queue->name . ':' . Job::JOB_TAB . ':' . $id, 'retry_times', 1); $this->jobId = $id; $this->periodic = $this->client->hGet($this->queue->name . ':' . Job::JOB_TAB . ':' . $id, 'periodic'); return $job; }