Пример #1
0
 /**
  * Pop a job
  *
  * @param string $key
  * @return mixed
  */
 public function pop($key)
 {
     $ret = $this->client->zrevrangebyscore($key, Util::now(), '-inf', array('limit' => array(0, 1)));
     if (!$ret) {
         return false;
     }
     // Delete error will lose the control job
     if (!$this->client->zrem($key, $ret[0])) {
         return false;
     }
     return $ret[0];
 }
Пример #2
0
 /**
  * Write job log
  *
  * @param string $str
  * @return $this
  */
 public function log($str)
 {
     $this->emit('log', $str);
     $this->client->rpush('q:job:' . $this->injectors['id'] . ':log', $str);
     $this->set('updated_at', Util::now());
     return $this;
 }