改名
This commit is contained in:
@@ -9,6 +9,7 @@ use PDO;
|
|||||||
use Snowflake\Abstracts\Pool;
|
use Snowflake\Abstracts\Pool;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Swoole\Error;
|
use Swoole\Error;
|
||||||
|
use Swoole\Runtime;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,6 +151,9 @@ class Connection extends Pool
|
|||||||
*/
|
*/
|
||||||
public function createClient(string $name, mixed $config): PDO
|
public function createClient(string $name, mixed $config): PDO
|
||||||
{
|
{
|
||||||
|
if (Coroutine::getCid() === -1) {
|
||||||
|
Runtime::enableCoroutine(false);
|
||||||
|
}
|
||||||
$link = new PDO($config['cds'], $config['username'], $config['password'], [
|
$link = new PDO($config['cds'], $config['username'], $config['password'], [
|
||||||
PDO::ATTR_EMULATE_PREPARES => false,
|
PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
PDO::ATTR_CASE => PDO::CASE_NATURAL,
|
PDO::ATTR_CASE => PDO::CASE_NATURAL,
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ use HttpServer\Http\Context;
|
|||||||
use Redis as SRedis;
|
use Redis as SRedis;
|
||||||
use Snowflake\Abstracts\Pool;
|
use Snowflake\Abstracts\Pool;
|
||||||
use Snowflake\Exception\RedisConnectException;
|
use Snowflake\Exception\RedisConnectException;
|
||||||
|
use Swoole\Coroutine;
|
||||||
|
use Swoole\Runtime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RedisClient
|
* Class RedisClient
|
||||||
@@ -36,10 +38,10 @@ class Redis extends Pool
|
|||||||
*/
|
*/
|
||||||
public function canCreate(string $name): bool
|
public function canCreate(string $name): bool
|
||||||
{
|
{
|
||||||
if (!isset($this->hasCreate[$name])) {
|
if (!isset(static::$hasCreate[$name])) {
|
||||||
$this->hasCreate[$name] = 0;
|
static::$hasCreate[$name] = 0;
|
||||||
}
|
}
|
||||||
return $this->hasCreate[$name] >= $this->max;
|
return static::$hasCreate[$name] >= $this->max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -69,6 +71,9 @@ class Redis extends Pool
|
|||||||
*/
|
*/
|
||||||
public function createClient(string $name, mixed $config): SRedis
|
public function createClient(string $name, mixed $config): SRedis
|
||||||
{
|
{
|
||||||
|
if (Coroutine::getCid() === -1) {
|
||||||
|
Runtime::enableCoroutine(false);
|
||||||
|
}
|
||||||
$redis = new SRedis();
|
$redis = new SRedis();
|
||||||
if (!$redis->pconnect($config['host'], (int)$config['port'], $config['timeout'])) {
|
if (!$redis->pconnect($config['host'], (int)$config['port'], $config['timeout'])) {
|
||||||
throw new RedisConnectException(sprintf('The Redis Connect %s::%d Fail.', $config['host'], $config['port']));
|
throw new RedisConnectException(sprintf('The Redis Connect %s::%d Fail.', $config['host'], $config['port']));
|
||||||
|
|||||||
Reference in New Issue
Block a user