From 45514189dc7f231d51939147972300e7b7ce486f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 6 Nov 2025 12:19:34 +0100 Subject: [PATCH] re-allow ext-redis 6.1 --- CHANGELOG.md | 2 +- Traits/Redis62ProxyTrait.php | 52 +++++++++++++++++++++++++++++ Traits/RedisCluster62ProxyTrait.php | 47 ++++++++++++++++++++++++++ Traits/RedisClusterProxy.php | 21 +----------- Traits/RedisProxy.php | 26 +-------------- Traits/RedisTrait.php | 4 +-- composer.json | 2 +- 7 files changed, 105 insertions(+), 49 deletions(-) create mode 100644 Traits/Redis62ProxyTrait.php create mode 100644 Traits/RedisCluster62ProxyTrait.php diff --git a/CHANGELOG.md b/CHANGELOG.md index fb3016a..8b0c2b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ CHANGELOG 7.4 --- - * Bump ext-redis to 6.2 and ext-relay to 0.12 minimum + * Bump ext-redis to 6.1 and ext-relay to 0.12 minimum 7.3 --- diff --git a/Traits/Redis62ProxyTrait.php b/Traits/Redis62ProxyTrait.php new file mode 100644 index 0000000..d29466c --- /dev/null +++ b/Traits/Redis62ProxyTrait.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Traits; + +if (version_compare(phpversion('redis'), '6.2.0', '>=')) { + /** + * @internal + */ + trait Redis62ProxyTrait + { + public function expiremember($key, $field, $ttl, $unit = null): \Redis|false|int + { + return $this->initializeLazyObject()->expiremember(...\func_get_args()); + } + + public function expirememberat($key, $field, $timestamp): \Redis|false|int + { + return $this->initializeLazyObject()->expirememberat(...\func_get_args()); + } + + public function getWithMeta($key): \Redis|array|false + { + return $this->initializeLazyObject()->getWithMeta(...\func_get_args()); + } + + public function serverName(): false|string + { + return $this->initializeLazyObject()->serverName(...\func_get_args()); + } + + public function serverVersion(): false|string + { + return $this->initializeLazyObject()->serverVersion(...\func_get_args()); + } + } +} else { + /** + * @internal + */ + trait Redis62ProxyTrait + { + } +} diff --git a/Traits/RedisCluster62ProxyTrait.php b/Traits/RedisCluster62ProxyTrait.php new file mode 100644 index 0000000..e96dee4 --- /dev/null +++ b/Traits/RedisCluster62ProxyTrait.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Traits; + +if (version_compare(phpversion('redis'), '6.2.0', '>=')) { + /** + * @internal + */ + trait RedisCluster62ProxyTrait + { + public function expiremember($key, $field, $ttl, $unit = null): \Redis|false|int + { + return $this->initializeLazyObject()->expiremember(...\func_get_args()); + } + + public function expirememberat($key, $field, $timestamp): \Redis|false|int + { + return $this->initializeLazyObject()->expirememberat(...\func_get_args()); + } + + public function getdel($key): mixed + { + return $this->initializeLazyObject()->getdel(...\func_get_args()); + } + + public function getWithMeta($key): \RedisCluster|array|false + { + return $this->initializeLazyObject()->getWithMeta(...\func_get_args()); + } + } +} else { + /** + * @internal + */ + trait RedisCluster62ProxyTrait + { + } +} diff --git a/Traits/RedisClusterProxy.php b/Traits/RedisClusterProxy.php index 2cde053..6bedcfa 100644 --- a/Traits/RedisClusterProxy.php +++ b/Traits/RedisClusterProxy.php @@ -24,6 +24,7 @@ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); */ class RedisClusterProxy extends \RedisCluster implements ResetInterface, LazyObjectInterface { + use RedisCluster62ProxyTrait; use RedisProxyTrait { resetLazyObject as reset; } @@ -273,16 +274,6 @@ class RedisClusterProxy extends \RedisCluster implements ResetInterface, LazyObj return $this->initializeLazyObject()->expireat(...\func_get_args()); } - public function expiremember($key, $field, $ttl, $unit = null): \Redis|false|int - { - return $this->initializeLazyObject()->expiremember(...\func_get_args()); - } - - public function expirememberat($key, $field, $timestamp): \Redis|false|int - { - return $this->initializeLazyObject()->expirememberat(...\func_get_args()); - } - public function expiretime($key): \RedisCluster|false|int { return $this->initializeLazyObject()->expiretime(...\func_get_args()); @@ -353,21 +344,11 @@ class RedisClusterProxy extends \RedisCluster implements ResetInterface, LazyObj return $this->initializeLazyObject()->get(...\func_get_args()); } - public function getWithMeta($key): \RedisCluster|array|false - { - return $this->initializeLazyObject()->getWithMeta(...\func_get_args()); - } - public function getbit($key, $value): \RedisCluster|false|int { return $this->initializeLazyObject()->getbit(...\func_get_args()); } - public function getdel($key): mixed - { - return $this->initializeLazyObject()->getdel(...\func_get_args()); - } - public function getex($key, $options = []): \RedisCluster|false|string { return $this->initializeLazyObject()->getex(...\func_get_args()); diff --git a/Traits/RedisProxy.php b/Traits/RedisProxy.php index 6c75c9a..7e99b60 100644 --- a/Traits/RedisProxy.php +++ b/Traits/RedisProxy.php @@ -24,6 +24,7 @@ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); */ class RedisProxy extends \Redis implements ResetInterface, LazyObjectInterface { + use Redis62ProxyTrait; use RedisProxyTrait { resetLazyObject as reset; } @@ -273,16 +274,6 @@ class RedisProxy extends \Redis implements ResetInterface, LazyObjectInterface return $this->initializeLazyObject()->expireAt(...\func_get_args()); } - public function expiremember($key, $field, $ttl, $unit = null): \Redis|false|int - { - return $this->initializeLazyObject()->expiremember(...\func_get_args()); - } - - public function expirememberat($key, $field, $timestamp): \Redis|false|int - { - return $this->initializeLazyObject()->expirememberat(...\func_get_args()); - } - public function expiretime($key): \Redis|false|int { return $this->initializeLazyObject()->expiretime(...\func_get_args()); @@ -448,11 +439,6 @@ class RedisProxy extends \Redis implements ResetInterface, LazyObjectInterface return $this->initializeLazyObject()->getTransferredBytes(...\func_get_args()); } - public function getWithMeta($key): \Redis|array|false - { - return $this->initializeLazyObject()->getWithMeta(...\func_get_args()); - } - public function getset($key, $value): \Redis|false|string { return $this->initializeLazyObject()->getset(...\func_get_args()); @@ -913,16 +899,6 @@ class RedisProxy extends \Redis implements ResetInterface, LazyObjectInterface return $this->initializeLazyObject()->select(...\func_get_args()); } - public function serverName(): false|string - { - return $this->initializeLazyObject()->serverName(...\func_get_args()); - } - - public function serverVersion(): false|string - { - return $this->initializeLazyObject()->serverVersion(...\func_get_args()); - } - public function set($key, $value, $options = null): \Redis|bool|string { return $this->initializeLazyObject()->set(...\func_get_args()); diff --git a/Traits/RedisTrait.php b/Traits/RedisTrait.php index 918336a..97233ed 100644 --- a/Traits/RedisTrait.php +++ b/Traits/RedisTrait.php @@ -193,7 +193,7 @@ trait RedisTrait } if (isset($params['sentinel']) && !class_exists(\Predis\Client::class) && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) { - throw new CacheException('Redis Sentinel support requires one of: "predis/predis", "ext-redis >= 5.2", "ext-relay".'); + throw new CacheException('Redis Sentinel support requires one of: "predis/predis", "ext-redis >= 6.1", "ext-relay".'); } foreach (['lazy', 'persistent', 'cluster'] as $option) { @@ -224,7 +224,7 @@ trait RedisTrait }; if (isset($params['sentinel']) && !is_a($class, \Predis\Client::class, true) && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) { - throw new CacheException(\sprintf('Cannot use Redis Sentinel: class "%s" does not extend "Predis\Client" and neither ext-redis >= 5.2 nor ext-relay have been found.', $class)); + throw new CacheException(\sprintf('Cannot use Redis Sentinel: class "%s" does not extend "Predis\Client" and neither ext-redis >= 6.1 nor ext-relay have been found.', $class)); } $isRedisExt = is_a($class, \Redis::class, true); diff --git a/composer.json b/composer.json index e5834e9..c8280d5 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "symfony/var-dumper": "^6.4|^7.0|^8.0" }, "conflict": { - "ext-redis": "<6.2", + "ext-redis": "<6.1", "ext-relay": "<0.12.1", "doctrine/dbal": "<3.6", "symfony/dependency-injection": "<6.4",