定義延遲隊列的兩種方式
一 、任務分發的時候指定
\App\Jobs\Jober::dispatch()->delay(20);
2、定義Jober時構造方法中指定
<?php
namespace App\Jobs;
---------------------------------------------------
class Timer implements ShouldQueue
{
-----------------------------------------------
public function __construct()
{
$this->delay(20);
}
/**
* Execute the job.
* @return void
*/
public function handle()
{
---------------------------------------------------
}
}
3、經過 delay
屬性指定
<?php
namespace App\Jobs;
---------------------------------------------------
class Timer implements ShouldQueue
{
public $delay = 30;
-----------------------------------------------
public function __construct()
{
}
/**
* Execute the job.
* @return void
*/
public function handle()
{
---------------------------------------------------
}
}