qqq
This commit is contained in:
@@ -10,6 +10,7 @@ declare(strict_types=1);
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
|
||||
use Database\DatabasesProviders;
|
||||
use Exception;
|
||||
use Kiri;
|
||||
use Kiri\Di\LocalService;
|
||||
@@ -22,6 +23,7 @@ use Kiri\Events\EventProvider;
|
||||
/**
|
||||
* Class BaseApplication
|
||||
* @package Kiri\Base
|
||||
* @property DatabasesProviders $connections
|
||||
*/
|
||||
abstract class BaseApplication extends Component
|
||||
{
|
||||
@@ -32,9 +34,6 @@ abstract class BaseApplication extends Component
|
||||
*/
|
||||
public string $storage = APP_PATH . 'storage';
|
||||
|
||||
public string $envPath = APP_PATH . '.env';
|
||||
|
||||
|
||||
public LocalService $localService;
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Kiri;
|
||||
|
||||
use Exception;
|
||||
use Kiri;
|
||||
use Kiri\Abstracts\{BaseApplication, Config, Kernel};
|
||||
use Kiri\Abstracts\{BaseApplication, Kernel};
|
||||
use Kiri\Di\LocalService;
|
||||
use Kiri\Di\Scanner;
|
||||
use Kiri\Error\ErrorHandler;
|
||||
@@ -31,8 +31,6 @@ use Symfony\Component\Console\{Application as ConsoleApplication,
|
||||
* Class Init
|
||||
*
|
||||
* @package Kiri
|
||||
*
|
||||
* @property-read Config $config
|
||||
*/
|
||||
class Application extends BaseApplication
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ class Pool extends Component
|
||||
* @param int $max
|
||||
* @param \Closure $closure
|
||||
*/
|
||||
public function initConnections($name, int $max, \Closure $closure): void
|
||||
public function created($name, int $max, \Closure $closure): void
|
||||
{
|
||||
if (!isset($this->_connections[$name])) {
|
||||
$this->_connections[$name] = new PoolItem($max, $closure);
|
||||
@@ -113,12 +113,13 @@ class Pool extends Component
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasChannel($name): bool
|
||||
{
|
||||
if (!isset($this->_connections[$name])) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return isset($this->_connections[$name]) && $this->_connections[$name] instanceof PoolItem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,10 +65,10 @@ class PoolItem
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function size(): bool
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function size(): int
|
||||
{
|
||||
return $this->_items->length();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class Redis extends Component
|
||||
|
||||
$length = \config('cache.redis.pool.max', 10);
|
||||
on(OnWorkerExit::class, [$this, 'destroy']);
|
||||
Kiri::getPool()->initConnections($config['host'], $length, static function () use ($config) {
|
||||
Kiri::getPool()->created($config['host'], $length, static function () use ($config) {
|
||||
$redis = new \Redis();
|
||||
if (!$redis->connect($config['host'], $config['port'], $config['timeout'])) {
|
||||
throw new RedisConnectException(sprintf('The Redis Connect %s::%d Fail.', $config['host'], $config['port']));
|
||||
|
||||
Reference in New Issue
Block a user