diff --git a/Adapter/PhpArrayAdapter.php b/Adapter/PhpArrayAdapter.php index 3967803..cb446ba 100644 --- a/Adapter/PhpArrayAdapter.php +++ b/Adapter/PhpArrayAdapter.php @@ -324,7 +324,7 @@ public function warmUp(array $values): array file_put_contents($tmpFile, $dump); @chmod($tmpFile, 0o666 & ~umask()); - unset($serialized, $value, $dump); + unset($value, $dump); @rename($tmpFile, $this->file); unset(self::$valuesCache[$this->file]); diff --git a/CHANGELOG.md b/CHANGELOG.md index 82fc7a0..a47cf84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,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/Redis63ProxyTrait.php b/Traits/Redis63ProxyTrait.php new file mode 100644 index 0000000..4925420 --- /dev/null +++ b/Traits/Redis63ProxyTrait.php @@ -0,0 +1,162 @@ + + * + * 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.3.0', '>=')) { + /** + * @internal + */ + trait Redis63ProxyTrait + { + public function delifeq($key, $value): \Redis|int|false + { + return $this->initializeLazyObject()->delifeq(...\func_get_args()); + } + + public function hexpire($key, $ttl, $fields, $mode = null): \Redis|array|false + { + return $this->initializeLazyObject()->hexpire(...\func_get_args()); + } + + public function hexpireat($key, $time, $fields, $mode = null): \Redis|array|false + { + return $this->initializeLazyObject()->hexpireat(...\func_get_args()); + } + + public function hexpiretime($key, $fields): \Redis|array|false + { + return $this->initializeLazyObject()->hexpiretime(...\func_get_args()); + } + + public function hgetdel($key, $fields): \Redis|array|false + { + return $this->initializeLazyObject()->hgetdel(...\func_get_args()); + } + + public function hgetex($key, $fields, $expiry = null): \Redis|array|false + { + return $this->initializeLazyObject()->hgetex(...\func_get_args()); + } + + public function hGetWithMeta($key, $member): mixed + { + return $this->initializeLazyObject()->hGetWithMeta(...\func_get_args()); + } + + public function hpersist($key, $fields): \Redis|array|false + { + return $this->initializeLazyObject()->hpersist(...\func_get_args()); + } + + public function hpexpire($key, $ttl, $fields, $mode = null): \Redis|array|false + { + return $this->initializeLazyObject()->hpexpire(...\func_get_args()); + } + + public function hpexpireat($key, $mstime, $fields, $mode = null): \Redis|array|false + { + return $this->initializeLazyObject()->hpexpireat(...\func_get_args()); + } + + public function hpexpiretime($key, $fields): \Redis|array|false + { + return $this->initializeLazyObject()->hpexpiretime(...\func_get_args()); + } + + public function hpttl($key, $fields): \Redis|array|false + { + return $this->initializeLazyObject()->hpttl(...\func_get_args()); + } + + public function hsetex($key, $fields, $expiry = null): \Redis|int|false + { + return $this->initializeLazyObject()->hsetex(...\func_get_args()); + } + + public function httl($key, $fields): \Redis|array|false + { + return $this->initializeLazyObject()->httl(...\func_get_args()); + } + + public function vadd($key, $values, $element, $options = null): \Redis|int|false + { + return $this->initializeLazyObject()->vadd(...\func_get_args()); + } + + public function vcard($key): \Redis|int|false + { + return $this->initializeLazyObject()->vcard(...\func_get_args()); + } + + public function vdim($key): \Redis|int|false + { + return $this->initializeLazyObject()->vdim(...\func_get_args()); + } + + public function vemb($key, $member, $raw = false): \Redis|array|false + { + return $this->initializeLazyObject()->vemb(...\func_get_args()); + } + + public function vgetattr($key, $member, $decode = true): \Redis|array|string|false + { + return $this->initializeLazyObject()->vgetattr(...\func_get_args()); + } + + public function vinfo($key): \Redis|array|false + { + return $this->initializeLazyObject()->vinfo(...\func_get_args()); + } + + public function vismember($key, $member): \Redis|bool + { + return $this->initializeLazyObject()->vismember(...\func_get_args()); + } + + public function vlinks($key, $member, $withscores = false): \Redis|array|false + { + return $this->initializeLazyObject()->vlinks(...\func_get_args()); + } + + public function vrandmember($key, $count = 0): \Redis|array|string|false + { + return $this->initializeLazyObject()->vrandmember(...\func_get_args()); + } + + public function vrange($key, $min, $max, $count = -1): \Redis|array|false + { + return $this->initializeLazyObject()->vrange(...\func_get_args()); + } + + public function vrem($key, $member): \Redis|int|false + { + return $this->initializeLazyObject()->vrem(...\func_get_args()); + } + + public function vsetattr($key, $member, $attributes): \Redis|int|false + { + return $this->initializeLazyObject()->vsetattr(...\func_get_args()); + } + + public function vsim($key, $member, $options = null): \Redis|array|false + { + return $this->initializeLazyObject()->vsim(...\func_get_args()); + } + } +} else { + /** + * @internal + */ + trait Redis63ProxyTrait + { + } +} 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/RedisCluster63ProxyTrait.php b/Traits/RedisCluster63ProxyTrait.php new file mode 100644 index 0000000..1ea8d3a --- /dev/null +++ b/Traits/RedisCluster63ProxyTrait.php @@ -0,0 +1,162 @@ + + * + * 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.3.0', '>=')) { + /** + * @internal + */ + trait RedisCluster63ProxyTrait + { + public function delifeq($key, $value): \RedisCluster|int|false + { + return $this->initializeLazyObject()->delifeq(...\func_get_args()); + } + + public function hexpire($key, $ttl, $fields, $mode = null): \RedisCluster|array|false + { + return $this->initializeLazyObject()->hexpire(...\func_get_args()); + } + + public function hexpireat($key, $time, $fields, $mode = null): \RedisCluster|array|false + { + return $this->initializeLazyObject()->hexpireat(...\func_get_args()); + } + + public function hexpiretime($key, $fields): \RedisCluster|array|false + { + return $this->initializeLazyObject()->hexpiretime(...\func_get_args()); + } + + public function hgetdel($key, $fields): \RedisCluster|array|false + { + return $this->initializeLazyObject()->hgetdel(...\func_get_args()); + } + + public function hgetex($key, $fields, $expiry = null): \RedisCluster|array|false + { + return $this->initializeLazyObject()->hgetex(...\func_get_args()); + } + + public function hgetWithMeta($key, $member): mixed + { + return $this->initializeLazyObject()->hgetWithMeta(...\func_get_args()); + } + + public function hpersist($key, $fields): \RedisCluster|array|false + { + return $this->initializeLazyObject()->hpersist(...\func_get_args()); + } + + public function hpexpire($key, $ttl, $fields, $mode = null): \RedisCluster|array|false + { + return $this->initializeLazyObject()->hpexpire(...\func_get_args()); + } + + public function hpexpireat($key, $mstime, $fields, $mode = null): \RedisCluster|array|false + { + return $this->initializeLazyObject()->hpexpireat(...\func_get_args()); + } + + public function hpexpiretime($key, $fields): \RedisCluster|array|false + { + return $this->initializeLazyObject()->hpexpiretime(...\func_get_args()); + } + + public function hpttl($key, $fields): \RedisCluster|array|false + { + return $this->initializeLazyObject()->hpttl(...\func_get_args()); + } + + public function hsetex($key, $fields, $expiry = null): \RedisCluster|int|false + { + return $this->initializeLazyObject()->hsetex(...\func_get_args()); + } + + public function httl($key, $fields): \RedisCluster|array|false + { + return $this->initializeLazyObject()->httl(...\func_get_args()); + } + + public function vadd($key, $values, $element, $options = null): \RedisCluster|int|false + { + return $this->initializeLazyObject()->vadd(...\func_get_args()); + } + + public function vcard($key): \RedisCluster|int|false + { + return $this->initializeLazyObject()->vcard(...\func_get_args()); + } + + public function vdim($key): \RedisCluster|int|false + { + return $this->initializeLazyObject()->vdim(...\func_get_args()); + } + + public function vemb($key, $member, $raw = false): \RedisCluster|array|false + { + return $this->initializeLazyObject()->vemb(...\func_get_args()); + } + + public function vgetattr($key, $member, $decode = true): \RedisCluster|array|string|false + { + return $this->initializeLazyObject()->vgetattr(...\func_get_args()); + } + + public function vinfo($key): \RedisCluster|array|false + { + return $this->initializeLazyObject()->vinfo(...\func_get_args()); + } + + public function vismember($key, $member): \RedisCluster|bool + { + return $this->initializeLazyObject()->vismember(...\func_get_args()); + } + + public function vlinks($key, $member, $withscores = false): \RedisCluster|array|false + { + return $this->initializeLazyObject()->vlinks(...\func_get_args()); + } + + public function vrandmember($key, $count = 0): \RedisCluster|array|string|false + { + return $this->initializeLazyObject()->vrandmember(...\func_get_args()); + } + + public function vrange($key, $min, $max, $count = -1): \RedisCluster|array|false + { + return $this->initializeLazyObject()->vrange(...\func_get_args()); + } + + public function vrem($key, $member): \RedisCluster|int|false + { + return $this->initializeLazyObject()->vrem(...\func_get_args()); + } + + public function vsetattr($key, $member, $attributes): \RedisCluster|int|false + { + return $this->initializeLazyObject()->vsetattr(...\func_get_args()); + } + + public function vsim($key, $member, $options = null): \RedisCluster|array|false + { + return $this->initializeLazyObject()->vsim(...\func_get_args()); + } + } +} else { + /** + * @internal + */ + trait RedisCluster63ProxyTrait + { + } +} diff --git a/Traits/RedisClusterProxy.php b/Traits/RedisClusterProxy.php index 2cde053..5dd798e 100644 --- a/Traits/RedisClusterProxy.php +++ b/Traits/RedisClusterProxy.php @@ -24,6 +24,8 @@ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); */ class RedisClusterProxy extends \RedisCluster implements ResetInterface, LazyObjectInterface { + use RedisCluster62ProxyTrait; + use RedisCluster63ProxyTrait; use RedisProxyTrait { resetLazyObject as reset; } @@ -273,16 +275,6 @@ public function expireat($key, $timestamp, $mode = null): \RedisCluster|bool 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 +345,11 @@ public function get($key): mixed 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..7742b5c 100644 --- a/Traits/RedisProxy.php +++ b/Traits/RedisProxy.php @@ -24,6 +24,8 @@ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); */ class RedisProxy extends \Redis implements ResetInterface, LazyObjectInterface { + use Redis62ProxyTrait; + use Redis63ProxyTrait; use RedisProxyTrait { resetLazyObject as reset; } @@ -273,16 +275,6 @@ public function expireAt($key, $timestamp, $mode = null): \Redis|bool 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 +440,6 @@ public function getTransferredBytes(): array 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 +900,6 @@ public function select($db): \Redis|bool 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 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra } 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 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra }; 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 59aab53..ae8f11a 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "symfony/var-dumper": "^7.4|^8.0" }, "conflict": { - "ext-redis": "<6.2", + "ext-redis": "<6.1", "ext-relay": "<0.12.1", "doctrine/dbal": "<4.3" },