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

Appearance settings

Commit 1d7b409

Browse filesBrowse files
committed
[Semaphore] Accept Relay connection
1 parent 0366a32 commit 1d7b409
Copy full SHA for 1d7b409

File tree

Expand file treeCollapse file tree

5 files changed

+52
-4
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+52
-4
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Semaphore/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.3
5+
---
6+
7+
* Add support for Relay PHP extension for Redis
8+
49
5.3
510
---
611

‎src/Symfony/Component/Semaphore/Store/RedisStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Semaphore/Store/RedisStore.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Semaphore\Store;
1313

14+
use Relay\Relay;
1415
use Symfony\Component\Semaphore\Exception\InvalidArgumentException;
1516
use Symfony\Component\Semaphore\Exception\SemaphoreAcquiringException;
1617
use Symfony\Component\Semaphore\Exception\SemaphoreExpiredException;
@@ -26,7 +27,7 @@
2627
class RedisStore implements PersistingStoreInterface
2728
{
2829
public function __construct(
29-
private \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis,
30+
private \Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis,
3031
) {
3132
}
3233

@@ -157,7 +158,7 @@ public function exists(Key $key): bool
157158

158159
private function evaluate(string $script, string $resource, array $args): mixed
159160
{
160-
if ($this->redis instanceof \Redis || $this->redis instanceof \RedisCluster) {
161+
if ($this->redis instanceof \Redis || $this->redis instanceof Relay || $this->redis instanceof \RedisCluster) {
161162
return $this->redis->eval($script, array_merge([$resource], $args), 1);
162163
}
163164

‎src/Symfony/Component/Semaphore/Store/StoreFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Semaphore/Store/StoreFactory.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Semaphore\Store;
1313

14+
use Relay\Relay;
1415
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1516
use Symfony\Component\Semaphore\Exception\InvalidArgumentException;
1617
use Symfony\Component\Semaphore\PersistingStoreInterface;
@@ -26,14 +27,14 @@ public static function createStore(#[\SensitiveParameter] object|string $connect
2627
{
2728
switch (true) {
2829
case $connection instanceof \Redis:
30+
case $connection instanceof Relay:
2931
case $connection instanceof \RedisArray:
3032
case $connection instanceof \RedisCluster:
3133
case $connection instanceof \Predis\ClientInterface:
3234
return new RedisStore($connection);
3335

3436
case !\is_string($connection):
3537
throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', $connection::class));
36-
3738
case str_starts_with($connection, 'redis://'):
3839
case str_starts_with($connection, 'rediss://'):
3940
if (!class_exists(AbstractAdapter::class)) {

‎src/Symfony/Component/Semaphore/Tests/Store/AbstractRedisStoreTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Semaphore/Tests/Store/AbstractRedisStoreTest.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Semaphore\Tests\Store;
1313

14+
use Relay\Relay;
1415
use Symfony\Component\Semaphore\PersistingStoreInterface;
1516
use Symfony\Component\Semaphore\Store\RedisStore;
1617

@@ -19,7 +20,7 @@
1920
*/
2021
abstract class AbstractRedisStoreTest extends AbstractStoreTest
2122
{
22-
abstract protected function getRedisConnection(): \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface;
23+
abstract protected function getRedisConnection(): \Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface;
2324

2425
public function getStore(): PersistingStoreInterface
2526
{
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Semaphore\Tests\Store;
13+
14+
use PHPUnit\Framework\SkippedTestSuiteError;
15+
use Relay\Relay;
16+
17+
/**
18+
* @requires extension relay
19+
*/
20+
class RelayStoreTest extends AbstractRedisStoreTest
21+
{
22+
protected function setUp(): void
23+
{
24+
$this->getRedisConnection()->flushDB();
25+
}
26+
27+
public static function setUpBeforeClass(): void
28+
{
29+
try {
30+
new Relay(...explode(':', getenv('REDIS_HOST')));
31+
} catch (\Relay\Exception $e) {
32+
throw new SkippedTestSuiteError($e->getMessage());
33+
}
34+
}
35+
36+
protected function getRedisConnection(): Relay
37+
{
38+
return new Relay(...explode(':', getenv('REDIS_HOST')));
39+
}
40+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.