Skip to content

Commit

Permalink
队列实现优化
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Feb 16, 2023
1 parent 70b3b7a commit cf1ebf6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/Driver/Pool/RedisPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ protected function createObject()
/** @var Config $config */
$config = $this->getConfig()->getExtraConf();
if($config instanceof ClusterConfig){
$info = new RedisCluster($config);
$info->connect();
return $info;
$item = new RedisCluster($config);
$item->connect();
$item->__lastPingTime = 0;
return $item;
}else{
$info = new Redis($config);
$info->connect();
return $info;
$item = new Redis($config);
$item->connect();
$item->__lastPingTime = 0;
return $item;
}
}

Expand All @@ -48,9 +50,6 @@ public function keepMin(?int $num = null): int
*/
protected function itemIntervalCheck($item): bool
{
if(!isset($item->__lastPingTime)){
$item->__lastPingTime = 0;
}
if(time() - $item->__lastPingTime > 10){
try{
$ret = $item->ping();
Expand Down

0 comments on commit cf1ebf6

Please sign in to comment.