diff --git a/src/Driver/Pool/RedisPool.php b/src/Driver/Pool/RedisPool.php index 1b3d315..fb82497 100644 --- a/src/Driver/Pool/RedisPool.php +++ b/src/Driver/Pool/RedisPool.php @@ -48,9 +48,14 @@ 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{ - return $item->ping(); + $ret = $item->ping(); + $item->__lastPingTime = time(); + return $ret; }catch (\Throwable $throwable){ //异常说明该链接出错了,return false 进行回收 return false; diff --git a/src/Driver/RedisQueue.php b/src/Driver/RedisQueue.php index aa0606f..486e9e4 100644 --- a/src/Driver/RedisQueue.php +++ b/src/Driver/RedisQueue.php @@ -4,7 +4,7 @@ namespace EasySwoole\Queue\Driver; -use EasySwoole\Pool\MagicPool; +use EasySwoole\Queue\Driver\Pool\RedisPool; use EasySwoole\Queue\Job; use EasySwoole\Queue\QueueDriverInterface; use EasySwoole\Redis\Config; @@ -20,11 +20,9 @@ class RedisQueue implements QueueDriverInterface public function __construct(Config $config,string $queueName = 'es_q') { - $this->pool = new MagicPool(function ()use($config){ - $redis = new Redis($config); - $redis->connect(); - return $redis; - }); + $poolConfig = new PoolConfig(); + $poolConfig->setExtraConf($config); + $this->pool = new RedisPool($poolConfig); $this->queueName = $queueName; }