getEvent(); $event->on(Event::RELEASE_ALL, [$this, 'destroy']); $event->on(Event::EVENT_AFTER_REQUEST, [$this, 'release']); $event->on(Event::SERVER_WORKER_START, [$this, 'createPool']); $event->on(Event::SERVER_TASK_START, [$this, 'createPool']); } /** * @throws ConfigException * @throws ComponentException */ public function createPool() { $connections = Snowflake::app()->getPool()->getRedis(); $config = $this->get_config(); $name = $config['host'] . ':' . $config['prefix'] . ':' . $config['databases']; $length = env('REDIS.POOL_LENGTH', 100); $connections->initConnections('redis:' . $name, true, $length); } /** * @param $name * @param $arguments * @return mixed * @throws */ public function __call($name, $arguments): mixed { if (method_exists($this, $name)) { $data = $this->{$name}(...$arguments); } else { $data = $this->proxy()->{$name}(...$arguments); } return $data; } /** * @param $key * @param int $timeout * @return bool * @throws Exception */ public function lock($key, $timeout = 5) { $script = <<