예제 #1
0
파일: JobQueueRedis.php 프로젝트: paladox/2
 /**
  * This function should not be called outside JobQueueRedis
  *
  * @param string $uid
  * @param RedisConnRef $conn
  * @return Job|bool Returns false if the job does not exist
  * @throws JobQueueError
  * @throws UnexpectedValueException
  */
 public function getJobFromUidInternal($uid, RedisConnRef $conn)
 {
     try {
         $data = $conn->hGet($this->getQueueKey('h-data'), $uid);
         if ($data === false) {
             return false;
             // not found
         }
         $item = $this->unserialize($data);
         if (!is_array($item)) {
             // this shouldn't happen
             throw new UnexpectedValueException("Could not find job with ID '{$uid}'.");
         }
         $title = Title::makeTitle($item['namespace'], $item['title']);
         $job = Job::factory($item['type'], $title, $item['params']);
         $job->metadata['uuid'] = $item['uuid'];
         $job->metadata['timestamp'] = $item['timestamp'];
         // Add in attempt count for debugging at showJobs.php
         $job->metadata['attempts'] = $conn->hGet($this->getQueueKey('h-attempts'), $uid);
         return $job;
     } catch (RedisException $e) {
         $this->throwRedisException($conn, $e);
     }
 }
예제 #2
0
 /**
  * This function should not be called outside JobQueueRedis
  *
  * @param $uid string
  * @param $conn RedisConnRef
  * @return Job
  * @throws MWException
  */
 public function getJobFromUidInternal($uid, RedisConnRef $conn)
 {
     try {
         $item = unserialize($conn->hGet($this->getQueueKey('h-data'), $uid));
         if (!is_array($item)) {
             // this shouldn't happen
             throw new MWException("Could not find job with ID '{$uid}'.");
         }
         $title = Title::makeTitle($item['namespace'], $item['title']);
         $job = Job::factory($item['type'], $title, $item['params']);
         $job->metadata['uuid'] = $item['uuid'];
         return $job;
     } catch (RedisException $e) {
         $this->throwRedisException($this->server, $conn, $e);
     }
 }