This commit is contained in:
2021-02-23 16:56:34 +08:00
parent 3cef44886d
commit 7ae8d4ffc2
10 changed files with 500 additions and 492 deletions
+43 -43
View File
@@ -17,54 +17,54 @@ class ObjectPool extends \Snowflake\Abstracts\Pool
{
/**
* set pool max length
*/
public function init()
{
$this->max = 100;
}
/**
* set pool max length
*/
public function init()
{
$this->max = 100;
}
/**
* @param array $config
* @param bool $isMaster
* @return mixed
* @throws Exception
*/
public function getConnection(array $config, bool $isMaster): mixed
{
if (is_object($config[0])) {
$config[0] = get_class($config[0]) ;
}
return $this->get(md5($config[0]), $config);
}
/**
* @param array $config
* @param bool $isMaster
* @return mixed
* @throws Exception
*/
public function get(mixed $config, bool $isMaster = false): mixed
{
if (is_object($config)) {
return $config;
}
return $this->getFromChannel(md5($config), $config);
}
/**
* @param string $name
* @param array $config
* @return mixed
* @throws ReflectionException
* @throws NotFindClassException
*/
public function createClient(string $name, array $config): mixed
{
// TODO: Implement createClient() method.
return Snowflake::createObject(array_shift($config));
}
/**
* @param string $name
* @param mixed $config
* @return mixed
* @throws ReflectionException
* @throws NotFindClassException
*/
public function createClient(string $name, mixed $config): mixed
{
// TODO: Implement createClient() method.
return Snowflake::createObject(array_shift($config));
}
/**
* @param string $name
* @param $object
*/
public function release(string $name, mixed $object)
{
if (method_exists($object, 'clean')) {
$object->clean();
}
$this->push($name, $object);
}
/**
* @param string $name
* @param $object
*/
public function release(string $name, mixed $object)
{
if (method_exists($object, 'clean')) {
$object->clean();
}
$this->push($name, $object);
}
}