From 26e443cc7c1d45f8b37e3355369ce82ba2e0d847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Thu, 16 Jul 2020 00:13:38 +0200 Subject: [PATCH] Allows RedisClusterProxy instance in Lock RedisStore --- Store/RedisStore.php | 8 ++++---- Tests/Store/StoreFactoryTest.php | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Store/RedisStore.php b/Store/RedisStore.php index 0e9241b..21d7116 100644 --- a/Store/RedisStore.php +++ b/Store/RedisStore.php @@ -33,13 +33,13 @@ class RedisStore implements StoreInterface private $initialTtl; /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient - * @param float $initialTtl the expiration delay of locks in seconds + * @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) { diff --git a/Tests/Store/StoreFactoryTest.php b/Tests/Store/StoreFactoryTest.php index 4e5f387..1d88638 100644 --- a/Tests/Store/StoreFactoryTest.php +++ b/Tests/Store/StoreFactoryTest.php @@ -61,6 +61,9 @@ public function validConnections() } 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];