/** * Stop tracking the status of a job. */ public function stop() { Resque::redis()->del((string) $this); }
/** * 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); } }
/** * Return Redis * * @return object Redis instance */ public function redis() { return Resque::redis(); }
/** * 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; }