改名
This commit is contained in:
@@ -109,7 +109,7 @@ abstract class Pool extends Component
|
|||||||
*/
|
*/
|
||||||
public function hasItem($name)
|
public function hasItem($name)
|
||||||
{
|
{
|
||||||
return $this->hasLength($name) > 0;
|
return $this->size($name) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ abstract class Pool extends Component
|
|||||||
* @param $name
|
* @param $name
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function hasLength($name)
|
public function size($name)
|
||||||
{
|
{
|
||||||
if (!isset($this->_items[$name])) {
|
if (!isset($this->_items[$name])) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class Connection extends Pool
|
|||||||
[$coroutineId, $coroutineName] = $this->getIndex($config['cds'], $isMaster);
|
[$coroutineId, $coroutineName] = $this->getIndex($config['cds'], $isMaster);
|
||||||
if (Context::hasContext($coroutineName)) {
|
if (Context::hasContext($coroutineName)) {
|
||||||
return Context::getContext($coroutineName);
|
return Context::getContext($coroutineName);
|
||||||
} else if (!$this->hasItem($coroutineName)) {
|
} else if ($this->size($coroutineName) < 1) {
|
||||||
return $this->saveClient($coroutineName, $this->nowClient($coroutineName, $config));
|
return $this->saveClient($coroutineName, $this->nowClient($coroutineName, $config));
|
||||||
} else {
|
} else {
|
||||||
return $this->getByChannel($coroutineName, $config);
|
return $this->getByChannel($coroutineName, $config);
|
||||||
@@ -165,10 +165,10 @@ class Connection extends Pool
|
|||||||
*/
|
*/
|
||||||
public function fill($name, $config)
|
public function fill($name, $config)
|
||||||
{
|
{
|
||||||
if ($this->hasLength($name) >= 10) {
|
if ($this->size($name) >= 10) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
for ($i = 0; $i < 10 - $this->hasLength($name); $i++) {
|
for ($i = 0; $i < 10 - $this->size($name); $i++) {
|
||||||
$this->push($name, $this->createConnect($config['cds'], $config['username'], $config['password']));
|
$this->push($name, $this->createConnect($config['cds'], $config['username'], $config['password']));
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
@@ -182,13 +182,13 @@ class Connection extends Pool
|
|||||||
*/
|
*/
|
||||||
public function getByChannel($coroutineName, $config)
|
public function getByChannel($coroutineName, $config)
|
||||||
{
|
{
|
||||||
$this->info('client has :' . $this->hasLength($coroutineName));
|
$this->info('client has :' . $this->size($coroutineName));
|
||||||
[$time, $client] = $this->get($coroutineName, -1);
|
[$time, $client] = $this->get($coroutineName, -1);
|
||||||
if ($client instanceof PDO) {
|
if ($client instanceof PDO) {
|
||||||
return $this->saveClient($coroutineName, $client);
|
return $this->saveClient($coroutineName, $client);
|
||||||
}
|
}
|
||||||
unset($client);
|
unset($client);
|
||||||
if (!$this->hasItem($coroutineName)) {
|
if ($this->hasItem($coroutineName) < 1) {
|
||||||
return $this->saveClient($coroutineName, $this->nowClient($coroutineName, $config));
|
return $this->saveClient($coroutineName, $this->nowClient($coroutineName, $config));
|
||||||
}
|
}
|
||||||
return $this->getByChannel($coroutineName, $config);
|
return $this->getByChannel($coroutineName, $config);
|
||||||
@@ -215,7 +215,7 @@ class Connection extends Pool
|
|||||||
private function nowClient($coroutineName, $config)
|
private function nowClient($coroutineName, $config)
|
||||||
{
|
{
|
||||||
$client = $this->createConnect($config['cds'], $config['username'], $config['password']);
|
$client = $this->createConnect($config['cds'], $config['username'], $config['password']);
|
||||||
$this->success('create db client -> ' . $config['cds'] . ':' . $this->hasLength($coroutineName));
|
$this->success('create db client -> ' . $config['cds'] . ':' . $this->size($coroutineName));
|
||||||
if (isset(Context::getContext('begin_' . $coroutineName)[Coroutine::getCid()])) {
|
if (isset(Context::getContext('begin_' . $coroutineName)[Coroutine::getCid()])) {
|
||||||
$number = Context::getContext('begin_' . $coroutineName)[Coroutine::getCid()];
|
$number = Context::getContext('begin_' . $coroutineName)[Coroutine::getCid()];
|
||||||
$number > 0 && $client->beginTransaction();
|
$number > 0 && $client->beginTransaction();
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class Redis extends Pool
|
|||||||
if (Context::hasContext($coroutineName)) {
|
if (Context::hasContext($coroutineName)) {
|
||||||
return Context::getContext($coroutineName);
|
return Context::getContext($coroutineName);
|
||||||
} else if (!$this->hasItem($coroutineName)) {
|
} else if (!$this->hasItem($coroutineName)) {
|
||||||
$this->success('create redis client -> ' . $config['host'] . ':' . $this->hasLength($coroutineName));
|
$this->success('create redis client -> ' . $config['host'] . ':' . $this->size($coroutineName));
|
||||||
return $this->saveClient($coroutineName, $this->createConnect($config));
|
return $this->saveClient($coroutineName, $this->createConnect($config));
|
||||||
}
|
}
|
||||||
return $this->getByChannel($coroutineName, $config);
|
return $this->getByChannel($coroutineName, $config);
|
||||||
@@ -55,9 +55,9 @@ class Redis extends Pool
|
|||||||
*/
|
*/
|
||||||
public function getByChannel($coroutineName, $config)
|
public function getByChannel($coroutineName, $config)
|
||||||
{
|
{
|
||||||
$this->info('redis client has :' . $this->hasLength($coroutineName));
|
$this->info('redis client has :' . $this->size($coroutineName));
|
||||||
if (!$this->hasItem($coroutineName)) {
|
if (!$this->hasItem($coroutineName)) {
|
||||||
$this->success('create redis client -> ' . $config['host'] . ':' . $this->hasLength($coroutineName));
|
$this->success('create redis client -> ' . $config['host'] . ':' . $this->size($coroutineName));
|
||||||
return $this->saveClient($coroutineName, $this->createConnect($config));
|
return $this->saveClient($coroutineName, $this->createConnect($config));
|
||||||
}
|
}
|
||||||
[$time, $client] = $this->get($coroutineName, -1);
|
[$time, $client] = $this->get($coroutineName, -1);
|
||||||
|
|||||||
Reference in New Issue
Block a user