Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4212cd5

Browse files
committed
make both options redis_sentinel and sentinel_master available everywhere
1 parentdc330b0 commit4212cd5

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

‎src/Symfony/Component/Cache/CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.1
5+
---
6+
7+
* Add option`sentinel_master` as an alias for`redis_sentinel`
8+
49
7.0
510
---
611

‎src/Symfony/Component/Cache/Traits/RedisTrait.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra
169169

170170
$params +=$query +$options +self::$defaultConnectionOptions;
171171

172+
if ($params['redis_sentinel'] &&isset($params['sentinel_master'])) {
173+
thrownewInvalidArgumentException('Cannot use both "redis_sentinel" and "sentinel_master" at the same time.');
174+
}
175+
176+
$params['redis_sentinel'] ??=$params['sentinel_master'] ??null;
177+
172178
if (isset($params['redis_sentinel']) && !class_exists(\Predis\Client::class) && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) {
173179
thrownewCacheException('Redis Sentinel support requires one of: "predis/predis", "ext-redis >= 5.2", "ext-relay".');
174180
}

‎src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisExtIntegrationTest.php‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ public function testConnectionClaimAndRedeliver()
220220
$connection->ack($message['id']);
221221
}
222222

223-
publicfunctiontestSentinel()
223+
/**
224+
* @dataProvider
225+
*/
226+
publicfunctiontestSentinel(string$sentinelOptionName)
224227
{
225228
if (!$hosts =getenv('REDIS_SENTINEL_HOSTS')) {
226229
$this->markTestSkipped('REDIS_SENTINEL_HOSTS env var is not defined.');
@@ -234,7 +237,7 @@ public function testSentinel()
234237

235238
$connection = Connection::fromDsn($dsn,
236239
['delete_after_ack' =>true,
237-
'sentinel_master' =>getenv('MESSENGER_REDIS_SENTINEL_MASTER') ?:null,
240+
$sentinelOptionName =>getenv('MESSENGER_REDIS_SENTINEL_MASTER') ?:null,
238241
],$this->redis);
239242

240243
$connection->add('1', []);
@@ -249,6 +252,12 @@ public function testSentinel()
249252
$connection->cleanup();
250253
}
251254

255+
publicfunctionsentinelOptionNames():iterable
256+
{
257+
yield'redis_sentinel';
258+
yield'sentinel_master';
259+
}
260+
252261
publicfunctiontestLazySentinel()
253262
{
254263
$connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'),

‎src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ public function __construct(array $options, \Redis|Relay|\RedisCluster $redis =
7878
$host =$options['host'];
7979
$port =$options['port'];
8080
$auth =$options['auth'];
81-
$sentinelMaster =$options['sentinel_master'];
81+
82+
if ($options['redis_sentinel'] &&isset($options['sentinel_master'])) {
83+
thrownewInvalidArgumentException('Cannot use both "redis_sentinel" and "sentinel_master" at the same time.');
84+
}
85+
86+
$sentinelMaster =$options['sentinel_master'] ??$options['redis_sentinel'];
8287

8388
if (null !==$sentinelMaster && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) {
8489
thrownewInvalidArgumentException('Redis Sentinel support requires ext-redis>=5.2, or ext-relay.');

‎src/Symfony/Component/Messenger/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.1
55
---
66

7+
* Add option`redis_sentinel` as an alias for`sentinel_master`
78
* Add`--all` option to the`messenger:consume` command
89

910
7.0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp