PHP code example of pfinal / queue
1. Go to this page and download the library: Download pfinal/queue library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pfinal / queue example snippets
$queue->push(function (Job $job) use ($email, $text) {
if( Mail::send($email, $text) ){
//任务执行成功后删除job
$job->delete();
}else{
if ($this->attempts() > 10) {
//todo 处理任务失败业务逻辑
//...
$job->fail();
}else{
//延时重试
$delay = $this->attempts() * 5;
$job->release($delay);
}
}
});