改名
This commit is contained in:
@@ -33,7 +33,10 @@ class ObjectPool extends \Snowflake\Abstracts\Pool
|
||||
if (is_object($config)) {
|
||||
return $config;
|
||||
}
|
||||
$object = $this->getFromChannel($name = md5($config), [$config, $construct]);
|
||||
|
||||
$className = hash('sha384', $config);
|
||||
|
||||
$object = $this->getFromChannel($className, [$config, $construct]);
|
||||
if (method_exists($object, 'clean')) {
|
||||
$object->clean();
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Pool;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Swoole\Timer;
|
||||
|
||||
trait Timeout
|
||||
{
|
||||
|
||||
public int $creates = -1;
|
||||
|
||||
|
||||
public int $lastTime = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function Heartbeat_detection()
|
||||
{
|
||||
if ($this->lastTime == 0) {
|
||||
return;
|
||||
}
|
||||
if ($this->lastTime + 60 < time()) {
|
||||
$this->flush(0);
|
||||
} else if ($this->lastTime + 30 < time()) {
|
||||
$this->flush(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $retain_number
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function flush($retain_number)
|
||||
{
|
||||
$channels = $this->getChannels();
|
||||
foreach ($channels as $name => $channel) {
|
||||
$names[] = $name;
|
||||
$this->pop($channel, $name, $retain_number);
|
||||
}
|
||||
if ($retain_number == 0) {
|
||||
$this->debug('release Timer::tick');
|
||||
Timer::clear($this->creates);
|
||||
$this->creates = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $channel
|
||||
* @param $name
|
||||
* @param $retain_number
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function pop($channel, $name, $retain_number)
|
||||
{
|
||||
while ($channel->length() > $retain_number) {
|
||||
$connection = $channel->pop();
|
||||
if ($connection) {
|
||||
unset($connection);
|
||||
}
|
||||
$this->desc($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user