Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5cc0895

Browse files
committed
Allows RedisClusterProxy instance in Lock RedisStore
1 parent 63d886f commit 5cc0895

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private function init($redisClient, string $namespace, int $defaultLifetime, ?Ma
8484
*
8585
* @throws InvalidArgumentException when the DSN is invalid
8686
*
87-
* @return \Redis|\RedisCluster|\Predis\ClientInterface According to the "class" option
87+
* @return \Redis|\RedisCluster|RedisClusterProxy|RedisProxy|\Predis\ClientInterface According to the "class" option
8888
*/
8989
public static function createConnection($dsn, array $options = [])
9090
{

src/Symfony/Component/Lock/Store/RedisStore.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ class RedisStore implements StoreInterface
3333
private $initialTtl;
3434

3535
/**
36-
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
37-
* @param float $initialTtl the expiration delay of locks in seconds
36+
* @param \Redis|\RedisArray|\RedisCluster|RedisProxy|RedisClusterProxy\Predis\ClientInterface $redisClient
37+
* @param float $initialTtl the expiration delay of locks in seconds
3838
*/
3939
public function __construct($redisClient, float $initialTtl = 300.0)
4040
{
41-
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy) {
42-
throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient)));
41+
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy && !$redisClient instanceof RedisClusterProxy) {
42+
throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster, RedisProxy, RedisClusterProxy or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient)));
4343
}
4444

4545
if ($initialTtl <= 0) {

src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public function validConnections()
6161
}
6262
if (class_exists(\Redis::class) && class_exists(AbstractAdapter::class)) {
6363
yield ['redis://localhost', RedisStore::class];
64+
yield ['redis://localhost?lazy=1', RedisStore::class];
65+
yield ['redis://localhost?redis_cluster=1', RedisStore::class];
66+
yield ['redis://localhost?redis_cluster=1&lazy=1', RedisStore::class];
6467
}
6568
if (class_exists(\PDO::class)) {
6669
yield ['sqlite:/tmp/sqlite.db', PdoStore::class];

0 commit comments

Comments
 (0)