From 2641f031c1f1f330cbd3fd9add785cdaec17aa62 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 20 Aug 2023 19:32:17 +0200 Subject: [PATCH] Update for amphp/redis:^2 --- src/Db/Driver/Redis.php | 11 +++++++---- src/Db/RedisArray.php | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Db/Driver/Redis.php b/src/Db/Driver/Redis.php index 293143a41c..1a44fcf820 100644 --- a/src/Db/Driver/Redis.php +++ b/src/Db/Driver/Redis.php @@ -16,12 +16,15 @@ namespace danog\MadelineProto\Db\Driver; -use Amp\Redis\Redis as RedisRedis; +use Amp\Redis\Connection\ReconnectingRedisLink; +use Amp\Redis\RedisClient; use Amp\Redis\RedisConfig; use Amp\Redis\RemoteExecutorFactory; use Amp\Sync\LocalKeyedMutex; use danog\MadelineProto\Settings\Database\Redis as DatabaseRedis; +use function Amp\Redis\createRedisConnector; + /** * Redis driver wrapper. * @@ -29,11 +32,11 @@ */ final class Redis { - /** @var array */ + /** @var array */ private static array $connections = []; private static ?LocalKeyedMutex $mutex = null; - public static function getConnection(DatabaseRedis $settings): RedisRedis + public static function getConnection(DatabaseRedis $settings): RedisClient { self::$mutex ??= new LocalKeyedMutex; $dbKey = $settings->getKey(); @@ -45,7 +48,7 @@ public static function getConnection(DatabaseRedis $settings): RedisRedis ->withPassword($settings->getPassword()) ->withDatabase($settings->getDatabase()); - self::$connections[$dbKey] = new RedisRedis((new RemoteExecutorFactory($config))->createQueryExecutor()); + self::$connections[$dbKey] = new RedisClient(new ReconnectingRedisLink(createRedisConnector($config))); self::$connections[$dbKey]->ping(); } } finally { diff --git a/src/Db/RedisArray.php b/src/Db/RedisArray.php index 994fd0e7ca..1c28378565 100644 --- a/src/Db/RedisArray.php +++ b/src/Db/RedisArray.php @@ -16,7 +16,7 @@ namespace danog\MadelineProto\Db; -use Amp\Redis\Redis as RedisRedis; +use Amp\Redis\RedisClient; use danog\MadelineProto\Db\Driver\Redis; use danog\MadelineProto\Logger; use danog\MadelineProto\Settings\Database\Redis as DatabaseRedis; @@ -32,7 +32,7 @@ */ final class RedisArray extends DriverArray { - private RedisRedis $db; + private RedisClient $db; /** * Initialize on startup.