Example #1
0
 /**
  * Get metadata.
  * At first call metadata will be loaded from redis.
  *
  * @return Metadata
  */
 public function getMetadata()
 {
     if ($this->metadata === null) {
         $this->metadata = new Metadata($this->owner, $this->id);
         $this->metadata->refresh();
     }
     return $this->metadata;
 }
Example #2
0
 /**
  * Build a job.
  * Null is returned if job cannot be created.
  *
  * @return Job|null
  */
 public function build()
 {
     if (!$this->metadata->type) {
         $this->metadata->type = Yiiq::TYPE_SIMPLE;
     }
     if (!$this->metadata->queue) {
         $this->metadata->queue = Yiiq::DEFAULT_QUEUE;
     }
     $overwrite = $this->metadata->type === Yiiq::TYPE_REPEATABLE;
     if (!$this->metadata->save($overwrite)) {
         return;
     }
     $job = new Job($this->owner, $this->id);
     $job->metadata = $this->metadata;
     return $job;
 }
Example #3
0
 /**
  * Does job with given id exist.
  *
  * @param  string  $id
  * @return boolean
  */
 public function exists($id)
 {
     $key = Metadata::getKey($this, $id);
     return \Yii::app()->redis->getClient()->exists($key);
 }