This commit is contained in:
2021-02-20 13:35:17 +08:00
parent b140054ce9
commit 9ce45e39e8
6 changed files with 23 additions and 20 deletions
+7 -7
View File
@@ -52,7 +52,7 @@ class Connection extends Pool
*/
public function inTransaction($cds): bool
{
return Context::getContext('begin_' . $this->name($cds, true)) == 0;
return Context::getContext('begin_' . $this->name('mysql', $cds, true)) == 0;
}
/**
@@ -60,7 +60,7 @@ class Connection extends Pool
*/
public function beginTransaction($coroutineName)
{
$coroutineName = $this->name($coroutineName, true);
$coroutineName = $this->name('mysql', $coroutineName, true);
if (!Context::hasContext('begin_' . $coroutineName)) {
Context::setContext('begin_' . $coroutineName, 0);
}
@@ -79,7 +79,7 @@ class Connection extends Pool
*/
public function commit($coroutineName)
{
$coroutineName = $this->name($coroutineName, true);
$coroutineName = $this->name('mysql', $coroutineName, true);
if (!Context::hasContext('begin_' . $coroutineName)) {
return;
}
@@ -104,7 +104,7 @@ class Connection extends Pool
*/
private function getIndex($name, $isMaster = false): array
{
return [Coroutine::getCid(), $this->name($name, $isMaster)];
return [Coroutine::getCid(), $this->name('mysql', $name, $isMaster)];
}
/**
@@ -112,7 +112,7 @@ class Connection extends Pool
*/
public function rollback($coroutineName)
{
$coroutineName = $this->name($coroutineName, true);
$coroutineName = $this->name('mysql', $coroutineName, true);
if (!Context::hasContext('begin_' . $coroutineName)) {
return;
}
@@ -136,7 +136,7 @@ class Connection extends Pool
*/
public function getConnection(array $config, $isMaster = false): mixed
{
$coroutineName = $this->name($config['cds'], $isMaster);
$coroutineName = $this->name('mysql', $config['cds'], $isMaster);
if (!isset($this->hasCreate[$coroutineName])) {
$this->hasCreate[$coroutineName] = 0;
}
@@ -211,7 +211,7 @@ class Connection extends Pool
*/
public function release($coroutineName, $isMaster)
{
$coroutineName = $this->name($coroutineName, $isMaster);
$coroutineName = $this->name('mysql', $coroutineName, $isMaster);
if (!$this->hasClient($coroutineName)) {
return;
}
+3 -3
View File
@@ -42,7 +42,7 @@ class Redis extends Pool
public function getConnection(array $config, $isMaster = false): mixed
{
$name = $config['host'] . ':' . $config['prefix'] . ':' . $config['databases'];
$coroutineName = $this->name('redis:' . $name, $isMaster);
$coroutineName = $this->name('redis', 'redis:' . $name, $isMaster);
if (($redis = Context::getContext($coroutineName)) instanceof \Redis) {
return $redis;
}
@@ -105,7 +105,7 @@ class Redis extends Pool
public function release(array $config, $isMaster = false)
{
$name = $config['host'] . ':' . $config['prefix'] . ':' . $config['databases'];
$coroutineName = $this->name('redis:' . $name, $isMaster);
$coroutineName = $this->name('redis', 'redis:' . $name, $isMaster);
if (!Context::hasContext($coroutineName)) {
return;
}
@@ -121,7 +121,7 @@ class Redis extends Pool
public function destroy(array $config, $isMaster = false)
{
$name = $config['host'] . ':' . $config['prefix'] . ':' . $config['databases'];
$coroutineName = $this->name('redis:' . $name, $isMaster);
$coroutineName = $this->name('redis', 'redis:' . $name, $isMaster);
if (!Context::hasContext($coroutineName)) {
return;
}
+1
View File
@@ -40,6 +40,7 @@ trait Timeout
{
$channels = $this->getChannels();
foreach ($channels as $name => $channel) {
$this->debug('release ' . $name);
$this->pop($channel, $name, $retain_number);
}
if ($retain_number == 0) {