1, 'max' => 100]; $clients = $this->getPool()->get($coroutineName, $this->create($coroutineName, $config), $pool['min'] ?? 1); return Context::setContext($coroutineName, $clients); } /** * @param string $name * @param mixed $config * @return Closure */ public function create(string $name, mixed $config): Closure { return static function () use ($name, $config) { return Kiri::getDi()->create(\Kiri\Cache\Base\Redis::class, [$config]); }; } /** * @param array $config * @param bool $isMaster * @throws ConfigException * @throws Exception */ public function release(array $config, bool $isMaster = false) { $coroutineName = $config['host']; if (!Context::hasContext($coroutineName)) { return; } $this->getPool()->push($coroutineName, Context::getContext($coroutineName)); Context::remove($coroutineName); } /** * @param array $config * @param bool $isMaster * @throws Exception */ public function destroy(array $config, bool $isMaster = false) { $this->getPool()->clean($config['host']); Context::remove($config['host']); } /** * @param array $config * @param bool $isMaster * @throws Exception */ public function connection_clear(array $config, bool $isMaster = false) { $this->getPool()->clean($config['host']); } /** * @return Pool * @throws Exception */ public function getPool(): Pool { return Kiri::getDi()->get(Pool::class); } /** * @param $name * @param $isMaster * @param $max * @throws Exception */ public function initConnections($name, $isMaster, $max) { $this->getPool()->initConnections($name, $isMaster, $max); } }