diff --git a/src/extension/CacheTrait.php b/src/extension/CacheTrait.php index 8245b03..4674ce2 100644 --- a/src/extension/CacheTrait.php +++ b/src/extension/CacheTrait.php @@ -1,66 +1,16 @@ setHostAndPort(); - $this->cache = new Client([ - 'scheme' => 'tcp', - 'host' => $this->host, - 'port' => $this->port, - ]); - // select db - $db = ConfigHelper::getNestedParam(ConfigInterface::CACHE, ConfigInterface::DATABASE); - if ($db !== null) { - $this->cache->select($db); - } - // enter password - $password = env('REDIS_PASSWORD'); - if ($password !== null) { - $this->cache->auth($password); - } - } - - private function setHostAndPort() : void - { - $cacheEntity = ConfigHelper::getNestedParam(ConfigInterface::CACHE, $this->entity); - $this->host = empty($cacheEntity[ConfigInterface::HOST]) ? null : $cacheEntity[ConfigInterface::HOST]; - if ($this->host === null) { - $this->host = env('REDIS_HOST'); - if ($this->host === null) { - $this->host = ConfigInterface::DEFAULT_REDIS_HOST; - } - } - - $this->port = empty($cacheEntity[ConfigInterface::PORT]) ? null : $cacheEntity[ConfigInterface::PORT]; - if ($this->port === null) { - $this->port = env('REDIS_PORT'); - if ($this->port === null) { - $this->port = ConfigInterface::DEFAULT_REDIS_PORT; - } - } - } - /** * @param string $key * @param \League\Fractal\Resource\Collection | \League\Fractal\Resource\Item $val @@ -68,7 +18,7 @@ private function setHostAndPort() : void */ private function set(string $key, $val) { - return $this->cache->set($key, $this->ser($val)); + return Redis::set($key, $this->ser($val)); } /** @@ -77,7 +27,7 @@ private function set(string $key, $val) */ private function get(string $key) { - $data = $this->cache->get($key); + $data = Redis::get($key); if ($data === null) { return null; } diff --git a/src/extension/OptionsTrait.php b/src/extension/OptionsTrait.php index e8c81f4..222eecb 100644 --- a/src/extension/OptionsTrait.php +++ b/src/extension/OptionsTrait.php @@ -83,10 +83,6 @@ private function setConfigOptions(string $calledMethod) : void $this->configOptions->setIsCached($entityCache[ConfigInterface::ENABLED]); } } - - if ($this->configOptions->isCached()) { - $this->cacheConn(); - } } /**