36 lines
619 B
PHP
36 lines
619 B
PHP
<?php
|
|
namespace App\Bean\Queue;
|
|
|
|
use App\Bean\Model\Base\BaseBean;
|
|
|
|
class QueueBaseBean extends BaseBean
|
|
{
|
|
protected $try_limt = 3;
|
|
protected $try_times = 0;
|
|
|
|
public function IncrTryTimes($num = 1): void
|
|
{
|
|
$this->try_times += $num;
|
|
}
|
|
|
|
public function checkTryTimes(): bool
|
|
{
|
|
if($this->try_times >= $this->try_limt) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function getTryTimes(): int
|
|
{
|
|
return $this->try_times;
|
|
}
|
|
|
|
function getDelaySeconds($seconds = 30): int
|
|
{
|
|
return $seconds * $this->try_times;
|
|
}
|
|
|
|
}
|
|
|