定义延迟队列的两种方式
一 、任务分发的时候指定
\App\Jobs\Jober::dispatch()->delay(20);
二、定义Jober时构造方法中指定
<?php
namespace App\Jobs;
---------------------------------------------------
class Timer implements ShouldQueue
{
-----------------------------------------------
public function __construct()
{
$this->delay(20);
}
/**
* Execute the job.
* @return void
*/
public function handle()
{
---------------------------------------------------
}
}
三、通过 delay
属性指定
<?php
namespace App\Jobs;
---------------------------------------------------
class Timer implements ShouldQueue
{
public $delay = 30;
-----------------------------------------------
public function __construct()
{
}
/**
* Execute the job.
* @return void
*/
public function handle()
{
---------------------------------------------------
}
}