bug #37590 Allows RedisClusterProxy instance in Lock RedisStore (jderusse)
This PR was merged into the 4.4 branch.
Discussion
----------
Allows RedisClusterProxy instance in Lock RedisStore
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #37476
| License | MIT
| Doc PR | /
This PR allow clients instance of RedisClusterProxy created by the StoreFactory in #28691 /cc @nicolas-grekas
Commits
-------
8ef63cd6bc
Allows RedisClusterProxy instance in Lock RedisStore
This commit is contained in:
commit
0eae7a6578
|
@ -84,7 +84,7 @@ trait RedisTrait
|
|||
*
|
||||
* @throws InvalidArgumentException when the DSN is invalid
|
||||
*
|
||||
* @return \Redis|\RedisCluster|\Predis\ClientInterface According to the "class" option
|
||||
* @return \Redis|\RedisCluster|RedisClusterProxy|RedisProxy|\Predis\ClientInterface According to the "class" option
|
||||
*/
|
||||
public static function createConnection($dsn, array $options = [])
|
||||
{
|
||||
|
|
|
@ -33,13 +33,13 @@ class RedisStore implements StoreInterface
|
|||
private $initialTtl;
|
||||
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
|
||||
* @param \Redis|\RedisArray|\RedisCluster|RedisProxy|RedisClusterProxy\Predis\ClientInterface $redisClient
|
||||
* @param float $initialTtl the expiration delay of locks in seconds
|
||||
*/
|
||||
public function __construct($redisClient, float $initialTtl = 300.0)
|
||||
{
|
||||
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy) {
|
||||
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)));
|
||||
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy && !$redisClient instanceof RedisClusterProxy) {
|
||||
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)));
|
||||
}
|
||||
|
||||
if ($initialTtl <= 0) {
|
||||
|
|
|
@ -61,6 +61,9 @@ class StoreFactoryTest extends TestCase
|
|||
}
|
||||
if (class_exists(\Redis::class) && class_exists(AbstractAdapter::class)) {
|
||||
yield ['redis://localhost', RedisStore::class];
|
||||
yield ['redis://localhost?lazy=1', RedisStore::class];
|
||||
yield ['redis://localhost?redis_cluster=1', RedisStore::class];
|
||||
yield ['redis://localhost?redis_cluster=1&lazy=1', RedisStore::class];
|
||||
}
|
||||
if (class_exists(\PDO::class)) {
|
||||
yield ['sqlite:/tmp/sqlite.db', PdoStore::class];
|
||||
|
|
Reference in New Issue