| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace App\Jobs\Timer;
- use Hhxsv5\LaravelS\Swoole\Timer\CronJob;
- use Illuminate\Support\Facades\Log;
- use Swoole\Timer;
- class OrderJob extends CronJob
- {
- public function interval()
- {
- // 5分钟执行一次
- return 5 * 60 * 1000; // 定时器间隔,单位为 ms
- }
- /**
- * @return bool
- */
- public function isImmediate()
- {
- return $this->isImmediate;
- }
- public function setTimerId($timerId)
- {
- $this->timerId = $timerId;
- }
- public function stop()
- {
- if ($this->timerId && Timer::exists($this->timerId)) {
- Timer::clear($this->timerId);
- }
- }
- /**
- * 运行
- */
- public function run()
- {
- Log::info(__METHOD__, ['start', '', microtime(true)]);
- $this->stop();
- }
- }
|