Skip to content

Commit

Permalink
Allows RedisClusterProxy instance in Lock RedisStore
Browse files Browse the repository at this point in the history
  • Loading branch information
jderusse committed Jul 23, 2020
1 parent 7ddc6df commit 26e443c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Store/RedisStore.php
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions Tests/Store/StoreFactoryTest.php
Expand Up @@ -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];
Expand Down

0 comments on commit 26e443c

Please sign in to comment.