改名
This commit is contained in:
@@ -107,11 +107,11 @@ class Connection extends Component
|
||||
public function fill()
|
||||
{
|
||||
$connections = $this->connections();
|
||||
$pool = Config::get('databases.pool.max',10);
|
||||
$pool = Config::get('databases.pool.max', 10);
|
||||
|
||||
$connections->initConnections('mysql', $this->cds, true, $pool);
|
||||
$connections->initConnections($this->cds, true, $pool);
|
||||
if (!empty($this->slaveConfig) && $this->cds != $this->slaveConfig['cds']) {
|
||||
$connections->initConnections('mysql', $this->slaveConfig['cds'], false, $pool);
|
||||
$connections->initConnections($this->slaveConfig['cds'], false, $pool);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,11 +53,10 @@ class Redis extends Component
|
||||
$connections = Snowflake::app()->getRedisFromPool();
|
||||
|
||||
$config = $this->get_config();
|
||||
$name = $config['host'] . ':' . $config['prefix'] . ':' . $config['databases'];
|
||||
|
||||
$length = (int)env('REDIS.POOL_LENGTH', 100);
|
||||
|
||||
$connections->initConnections('redis', $name, true, $length);
|
||||
$connections->initConnections('Redis:' . $config['host'], true, $length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -106,18 +106,6 @@ class ClientsPool extends Component
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*/
|
||||
protected function clearCreateLog($name): void
|
||||
{
|
||||
if (!isset(static::$hasCreate[$name])) {
|
||||
return;
|
||||
}
|
||||
static::$hasCreate[$name] = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Channel $channel
|
||||
* @param $name
|
||||
@@ -140,12 +128,11 @@ class ClientsPool extends Component
|
||||
|
||||
|
||||
/**
|
||||
* @param $driver
|
||||
* @param $name
|
||||
* @param false $isMaster
|
||||
* @param int $max
|
||||
*/
|
||||
public function initConnections($driver, $name, bool $isMaster = false, int $max = 60)
|
||||
public function initConnections($name, bool $isMaster = false, int $max = 60)
|
||||
{
|
||||
$name = $this->name($name, $isMaster);
|
||||
if (isset(static::$_connections[$name]) && static::$_connections[$name] instanceof Channel) {
|
||||
|
||||
@@ -113,11 +113,15 @@ class Connection extends Component
|
||||
if (($pdo = Context::getContext($coroutineName)) instanceof PDO) {
|
||||
return $pdo;
|
||||
}
|
||||
if (Coroutine::getCid() === -1) {
|
||||
$connections = $this->createClient($coroutineName, $config);
|
||||
} else {
|
||||
/** @var PDO $connections */
|
||||
$connections = $this->getPool()->getFromChannel($coroutineName);
|
||||
if (empty($connections)) {
|
||||
$connections = $this->createClient($coroutineName, $config);
|
||||
}
|
||||
}
|
||||
if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) {
|
||||
$number > 0 && $connections->beginTransaction();
|
||||
}
|
||||
@@ -125,6 +129,18 @@ class Connection extends Component
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $isMaster
|
||||
* @param $max
|
||||
* @throws Exception
|
||||
*/
|
||||
public function initConnections($name, $isMaster, $max)
|
||||
{
|
||||
$this->getPool()->initConnections($name, $isMaster, $max);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $config
|
||||
|
||||
@@ -126,4 +126,16 @@ class Redis extends Component
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $isMaster
|
||||
* @param $max
|
||||
* @throws Exception
|
||||
*/
|
||||
public function initConnections($name, $isMaster, $max)
|
||||
{
|
||||
$this->getPool()->initConnections($name, $isMaster, $max);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user