get_config(); $length = Config::get('cache.redis.pool.max', 10); $this->eventProvider->on(OnWorkerExit::class, [$this, 'destroy'], 0); $this->pool->initConnections($config['host'], $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 \RedisException */ public function waite($key, int $timeout = 5): bool { $time = time(); while (!$this->setNx($key, 1)) { if (time() - $time >= $timeout) { return FALSE; } usleep(1000); } $this->expire($key, $timeout); return TRUE; } /** * @param $key * @param int $timeout * @return bool|int * @throws Exception */ public function lock($key, int $timeout = 5): bool|int { $script = <<