/** * 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); } }
/** * Stop tracking the status of a job. */ public function stop() { Resque::redis()->del((string) $this); }
/** * 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); }
/** * Return Redis * * @return object Redis instance */ public function redis() { return Resque::redis(); }
public static function get($jobId) { $data = \resque\lib\Resque::Redis()->get('failed:' . $jobId); return unserialize($data); }
/** * 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; }
/** * Find the next available job from the specified queue and return an * instance of Resque_Job for it. * * @param string $queue The name of the queue to check for a job in. * @return null|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found. */ public static function reserve($queue) { $payload = Resque::pop($queue); if (!is_array($payload)) { return false; } return new Resque_Job($queue, $payload); }