public static function addJob(string $className, string $function, array $args = [], int $priority = 0) { $redis = Redis::get(); $queueJobs = new JobQueue($redis); $job = ['class' => $className, 'function' => $function, 'args' => $args]; $queueJobs->push($job, $priority); }
protected function copyJobs(JobQueue $src, JobQueue $dst, $jobs) { $total = 0; $totalOK = 0; $batch = array(); foreach ($jobs as $job) { ++$total; $batch[] = $job; if (count($batch) >= $this->mBatchSize) { $dst->push($batch); $totalOK += count($batch); $batch = array(); $dst->waitForBackups(); } } if (count($batch)) { $dst->push($batch); $totalOK += count($batch); $dst->waitForBackups(); } return array($total, $totalOK); }