定义延迟队列的两种方式
一 、任务分发的时候指定
\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()
{
---------------------------------------------------
}
}
原文地址:https://blog.51cto.com/suiwnet/2428598
时间: 2024-11-29 08:46:13