diff --git a/src/App.php b/src/App.php index f745c18..baee6eb 100644 --- a/src/App.php +++ b/src/App.php @@ -266,7 +266,7 @@ class App // If Redis is configured, add it to the pool. if ($redis->isAvailable()) { - $caches[] = new RedisCachePool($redis); + $caches[] = new RedisCachePool($redis->getUnderlyingRedis()); } $caches[] = new ArrayCachePool(); @@ -298,10 +298,6 @@ class App ); }); - $container->set(\Redis::class, function (Redis $redis) { - return $redis; - }); - $container->set(Laminator::class, function (ConfigurationService $configurationService, Databases $databases) { return new Laminator( APP_ROOT, diff --git a/src/Redis/Lua/AbstractLuaExtension.php b/src/Redis/Lua/AbstractLuaExtension.php index 051d6bb..80f86ab 100644 --- a/src/Redis/Lua/AbstractLuaExtension.php +++ b/src/Redis/Lua/AbstractLuaExtension.php @@ -4,10 +4,10 @@ namespace Benzine\Redis\Lua; abstract class AbstractLuaExtension { - protected \Redis $redis; + protected Redis $redis; protected ?string $hash = null; - public function __construct(\Redis $redis) + public function __construct(Redis $redis) { $this->redis = $redis; } @@ -29,9 +29,9 @@ abstract class AbstractLuaExtension public function load(): void { if (!$this->hash) { - $exists = $this->redis->script('exists', $this->getScript()); + $exists = $this->getUnderlyingRedis()->script('exists', $this->getScript()); if (!$exists[0]) { - $this->hash = $this->redis->script('load', $this->getScript()); + $this->hash = $this->getUnderlyingRedis()->script('load', $this->getScript()); } } //printf("Loaded \"%s\" as \"%s\"\n", $this->getFunctionNames()[0], $this->hash); diff --git a/src/Redis/Redis.php b/src/Redis/Redis.php index 0c9376a..6485ad9 100644 --- a/src/Redis/Redis.php +++ b/src/Redis/Redis.php @@ -50,10 +50,25 @@ class Redis } } + /** + * @return \Redis + */ + public function getUnderlyingRedis(): \Redis + { + return $this->redis; + } + + /** + * @return Logger + */ + public function getLogger(): Logger + { + return $this->logger; + } public function isAvailable(): bool { try { - $this->redis->ping('am I human?'); + $this->ping('am I human?'); return true; } catch (\RedisException $redisException) {