This commit is contained in:
2023-08-29 21:46:05 +08:00
parent cc723a7630
commit 9c8c8c6bb3
+6 -1
View File
@@ -63,6 +63,8 @@ class Connection extends Component
private int $storey = 0; private int $storey = 0;
protected int $timerId = -1;
/** /**
* @var bool * @var bool
* enable database cache * enable database cache
@@ -127,7 +129,7 @@ class Connection extends Component
*/ */
public function tick(): void public function tick(): void
{ {
Timer::tick(120000, fn() => $this->checkClientHealth($this->pool())); $this->timerId = Timer::tick(120000, fn() => $this->checkClientHealth($this->pool()));
} }
@@ -390,6 +392,9 @@ class Connection extends Component
*/ */
public function disconnect(): void public function disconnect(): void
{ {
if ($this->timerId > -1) {
Timer::clear($this->timerId);
}
$this->pool()->close($this->cds); $this->pool()->close($this->cds);
} }