コード例 #1
0
ファイル: Worker.php プロジェクト: timelessmemory/uhkklp
 /**
  * Notify Redis that we've finished working on a job, clearing the working
  * state and incrementing the job stats.
  */
 public function doneWorking()
 {
     $this->currentJob = null;
     Resque_Stat::incr('processed');
     Resque_Stat::incr('processed:' . (string) $this);
     Resque::redis()->del('worker:' . (string) $this);
 }
コード例 #2
0
ファイル: Job.php プロジェクト: timelessmemory/uhkklp
 /**
  * Retry the failed job for given times.
  */
 public function retry()
 {
     $retryTimes = Constant::$RETRY_TIMES;
     $expiredTime = Constant::$FAILED_TIMES_EXPIRED_TIME;
     $jobId = $this->payload['id'];
     if ($retryTimes > 0 && !empty($jobId)) {
         $failedTimes = (int) Resque_Stat::get('job:failed:' . $jobId);
         $enqueuedAt = ($failedTimes + 1) * Constant::$FAILED_JOB_DELAYED_TIME;
         if ($expiredTime > $enqueuedAt) {
             if ($expiredTime > 0 && 0 == $failedTimes) {
                 Resque_Stat::expire('job:failed:' . $jobId, $expiredTime);
             }
             if ($failedTimes < $retryTimes) {
                 $this->recreate($enqueuedAt);
                 Resque_Stat::incr('job:failed:' . $jobId);
             } else {
                 $this->recreate($enqueuedAt, true);
             }
         }
     }
 }