🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
},
"conflict": {
"ext-psr": "<1.1|>=2",
"ext-redis": "<6.2",
"ext-redis": "<6.1",
"ext-relay": "<0.12.1",
"amphp/amp": "<2.5",
"async-aws/core": "<1.5",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand Down
52 changes: 52 additions & 0 deletions src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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

Check failure on line 49 in src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php:49:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Redis62ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php (see https://psalm.dev/071)

Check failure on line 49 in src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php:49:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Redis62ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php (see https://psalm.dev/071)
{
}
}
47 changes: 47 additions & 0 deletions src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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

Check failure on line 44 in src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php:44:11: DuplicateClass: Class Symfony\Component\Cache\Traits\RedisCluster62ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php (see https://psalm.dev/071)

Check failure on line 44 in src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php:44:11: DuplicateClass: Class Symfony\Component\Cache\Traits\RedisCluster62ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php (see https://psalm.dev/071)
{
}
}
21 changes: 1 addition & 20 deletions src/Symfony/Component/Cache/Traits/RedisClusterProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -273,16 +274,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());
Expand Down Expand Up @@ -353,21 +344,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());
Expand Down
26 changes: 1 addition & 25 deletions src/Symfony/Component/Cache/Traits/RedisProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -273,16 +274,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());
Expand Down Expand Up @@ -448,11 +439,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());
Expand Down Expand Up @@ -913,16 +899,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());
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Cache/Traits/RedisTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Messenger/Bridge/Redis/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct(array $options, \Redis|Relay|\RedisCluster|null $red
$sentinelMaster = $options['sentinel'] ?? $options['redis_sentinel'] ?? $options['sentinel_master'] ?? null;

if (null !== $sentinelMaster && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) {
throw new InvalidArgumentException('Redis Sentinel support requires ext-redis>=5.2, or ext-relay.');
throw new InvalidArgumentException('Redis Sentinel support requires ext-redis>=6.1, or ext-relay.');
}

if (null !== $sentinelMaster && $redis instanceof \RedisCluster) {
Expand Down Expand Up @@ -697,6 +697,7 @@ public function getMessageCount(): int
}

// Iterate through the stream. See https://redis.io/commands/xrange/#iterating-a-stream.
$useExclusiveRangeInterval = version_compare(phpversion('redis'), '6.2.0', '>=');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this behave when ext-relay is used ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea. Here I only revert what I removed previously in #61955. If this doesn't work with relay a bugfix will have to be done in some older branch anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine then

$total = 0;
while (true) {
if (!$range = $redis->xRange($this->stream, $lastDeliveredId, '+', 100)) {
Expand All @@ -705,7 +706,11 @@ public function getMessageCount(): int

$total += \count($range);

$lastDeliveredId = preg_replace_callback('#\d+$#', static fn (array $matches) => (int) $matches[0] + 1, array_key_last($range));
if ($useExclusiveRangeInterval) {
$lastDeliveredId = preg_replace_callback('#\d+$#', static fn (array $matches) => (int) $matches[0] + 1, array_key_last($range));
} else {
$lastDeliveredId = '('.array_key_last($range);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Messenger/Bridge/Redis/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"symfony/var-dumper": "^6.4|^7.0|^8.0"
},
"conflict": {
"ext-redis": "<6.2",
"ext-redis": "<6.1",
"ext-relay": "<0.12"
},
"autoload": {
Expand Down
Loading