modify
This commit is contained in:
@@ -169,6 +169,18 @@ abstract class Pool extends Component
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
|
||||
|
||||
@@ -195,7 +195,9 @@ class Connection extends Pool
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var PDO $client */
|
||||
$this->releaseClients('rds', $coroutineName);
|
||||
|
||||
/** @var PDO $client */
|
||||
$client = Context::getContext($coroutineName);
|
||||
if ($client->inTransaction()) {
|
||||
$client->commit();
|
||||
@@ -222,7 +224,9 @@ class Connection extends Pool
|
||||
*/
|
||||
public function connection_clear()
|
||||
{
|
||||
$this->flush(0);
|
||||
$this->releaseClients('rds', 'rds');
|
||||
|
||||
$this->flush(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+22
-16
@@ -48,13 +48,13 @@ class Redis extends Pool
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $config
|
||||
* @return SRedis
|
||||
* @throws RedisConnectException
|
||||
* @throws Exception
|
||||
*/
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $config
|
||||
* @return SRedis
|
||||
* @throws RedisConnectException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createClient(string $name, mixed $config): SRedis
|
||||
{
|
||||
$this->printClients($config['host'], $name, true);
|
||||
@@ -89,6 +89,9 @@ class Redis extends Pool
|
||||
if (!Context::hasContext($coroutineName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->releaseClients($config['host'], $coroutineName);
|
||||
|
||||
$this->push($coroutineName, Context::getContext($coroutineName));
|
||||
$this->remove($coroutineName);
|
||||
$this->lastTime = time();
|
||||
@@ -104,10 +107,13 @@ class Redis extends Pool
|
||||
$name = $config['host'] . ':' . $config['prefix'] . ':' . $config['databases'];
|
||||
$coroutineName = $this->name('redis', 'redis:' . $name, $isMaster);
|
||||
if (Context::hasContext($coroutineName)) {
|
||||
$this->desc($coroutineName);
|
||||
$this->desc($coroutineName);
|
||||
|
||||
$this->remove($coroutineName);
|
||||
$this->remove($coroutineName);
|
||||
}
|
||||
|
||||
$this->releaseClients($config['host'], $coroutineName);
|
||||
|
||||
$this->clean($coroutineName);
|
||||
}
|
||||
|
||||
@@ -119,12 +125,12 @@ class Redis extends Pool
|
||||
Context::remove($coroutineName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $client
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $client
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkCanUse(string $name, mixed $client): bool
|
||||
{
|
||||
try {
|
||||
@@ -136,7 +142,7 @@ class Redis extends Pool
|
||||
$result = true;
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
$this->addError($exception, 'redis');
|
||||
$this->addError($exception, 'redis');
|
||||
$result = false;
|
||||
} finally {
|
||||
if (!$result) {
|
||||
|
||||
Reference in New Issue
Block a user