Beispiel #1
0
 /**
  * Stop tracking the status of a job.
  */
 public function stop()
 {
     Resque::redis()->del((string) $this);
 }
Beispiel #2
0
 /**
  * Return an object describing the job this worker is currently working on.
  *
  * @return object Object with details of current job.
  */
 public function job()
 {
     $job = Resque::redis()->get('worker:' . $this);
     if (!$job) {
         return array();
     } else {
         return json_decode($job, true);
     }
 }
Beispiel #3
0
 /**
  * Return Redis
  *
  * @return object Redis instance
  */
 public function redis()
 {
     return Resque::redis();
 }
Beispiel #4
0
 /**
  * Delete a statistic with the given name.
  *
  * @param string $stat The name of the statistic to delete.
  * @return boolean True if successful, false if not.
  */
 public static function clear($stat)
 {
     return (bool) Resque::redis()->del('stat:' . $stat);
 }
 /**
  * Pop a job off the delayed queue for a given timestamp.
  *
  * @param DateTime|int $timestamp Instance of DateTime or UNIX timestamp.
  * @return array Matching job at timestamp.
  */
 public static function nextItemForTimestamp($timestamp)
 {
     $timestamp = self::getTimestamp($timestamp);
     $key = 'delayed:' . $timestamp;
     $item = json_decode(Resque::redis()->lpop($key), true);
     self::cleanupTimestamp($key, $timestamp);
     return $item;
 }