modify
This commit is contained in:
@@ -157,30 +157,6 @@ abstract class Pool extends Component
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $cds
|
||||
* @param $coroutineName
|
||||
* @param false $isBefore
|
||||
* @throws Exception
|
||||
*/
|
||||
public function printClients($cds, $coroutineName, $isBefore = false)
|
||||
{
|
||||
$this->warning(($isBefore ? 'before ' : '') . 'create client[address: ' . $cds . ', ' . env('worker', 0) . ', coroutine: ' . Coroutine::getCid() . ', has num: ' . $this->size($coroutineName) . ']');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $cds
|
||||
* @param $coroutineName
|
||||
* @param false $isBefore
|
||||
* @throws Exception
|
||||
*/
|
||||
public function releaseClients($cds, $coroutineName)
|
||||
{
|
||||
$this->warning('release client[address: ' . $cds . ', ' . env('worker', 0) . ', coroutine: ' . Coroutine::getCid() . ', has num: ' . $this->size($coroutineName) . ']');
|
||||
}
|
||||
|
||||
|
||||
abstract public function createClient(string $name, mixed $config): mixed;
|
||||
|
||||
|
||||
|
||||
@@ -154,8 +154,6 @@ class Connection extends Pool
|
||||
*/
|
||||
public function createClient(string $name, mixed $config): PDO
|
||||
{
|
||||
$this->printClients($config['cds'], $name, true);
|
||||
// TODO: Implement createClient() method.
|
||||
$link = new PDO($config['cds'], $config['username'], $config['password'], [
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::ATTR_CASE => PDO::CASE_NATURAL,
|
||||
@@ -195,8 +193,6 @@ class Connection extends Pool
|
||||
return;
|
||||
}
|
||||
|
||||
$this->releaseClients('rds', $coroutineName);
|
||||
|
||||
/** @var PDO $client */
|
||||
$client = Context::getContext($coroutineName);
|
||||
if ($client->inTransaction()) {
|
||||
@@ -224,8 +220,6 @@ class Connection extends Pool
|
||||
*/
|
||||
public function connection_clear()
|
||||
{
|
||||
$this->releaseClients('rds', 'rds');
|
||||
|
||||
$this->flush(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Snowflake\Pool;
|
||||
|
||||
use HttpServer\Http\Context;
|
||||
use Redis as SRedis;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Snowflake\Exception\RedisConnectException;
|
||||
use Exception;
|
||||
use Snowflake\Abstracts\Pool;
|
||||
@@ -57,7 +56,6 @@ class Redis extends Pool
|
||||
*/
|
||||
public function createClient(string $name, mixed $config): SRedis
|
||||
{
|
||||
$this->printClients($config['host'], $name, true);
|
||||
$redis = new SRedis();
|
||||
if (!$redis->pconnect($config['host'], (int)$config['port'], $config['timeout'])) {
|
||||
throw new RedisConnectException(sprintf('The Redis Connect %s::%d Fail.', $config['host'], $config['port']));
|
||||
@@ -90,8 +88,6 @@ class Redis extends Pool
|
||||
return;
|
||||
}
|
||||
|
||||
$this->releaseClients($config['host'], $coroutineName);
|
||||
|
||||
$this->push($coroutineName, Context::getContext($coroutineName));
|
||||
$this->remove($coroutineName);
|
||||
$this->lastTime = time();
|
||||
@@ -111,10 +107,7 @@ class Redis extends Pool
|
||||
|
||||
$this->remove($coroutineName);
|
||||
}
|
||||
|
||||
$this->releaseClients($config['host'], $coroutineName);
|
||||
|
||||
$this->clean($coroutineName);
|
||||
$this->flush(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user