[Lock] use Predis\ClientInterface instead of Predis\Client
This commit is contained in:
parent
6723e60540
commit
5c01f0a7e5
@ -31,13 +31,13 @@ class RedisStore implements StoreInterface
|
||||
private $initialTtl;
|
||||
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
|
||||
* @param float $initialTtl the expiration delay of locks in seconds
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
|
||||
* @param float $initialTtl the expiration delay of locks in seconds
|
||||
*/
|
||||
public function __construct($redisClient, $initialTtl = 300.0)
|
||||
{
|
||||
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\Client && !$redisClient instanceof RedisProxy) {
|
||||
throw new InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\Client, %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) {
|
||||
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 ($initialTtl <= 0) {
|
||||
@ -139,11 +139,11 @@ class RedisStore implements StoreInterface
|
||||
return $this->redis->_instance($this->redis->_target($resource))->eval($script, array_merge([$resource], $args), 1);
|
||||
}
|
||||
|
||||
if ($this->redis instanceof \Predis\Client) {
|
||||
if ($this->redis instanceof \Predis\ClientInterface) {
|
||||
return \call_user_func_array([$this->redis, 'eval'], array_merge([$script, 1, $resource], $args));
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)));
|
||||
throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\ClientInterface, %s given', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,13 +22,13 @@ use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
||||
class StoreFactory
|
||||
{
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|\Memcached $connection
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|\Memcached $connection
|
||||
*
|
||||
* @return RedisStore|MemcachedStore
|
||||
*/
|
||||
public static function createStore($connection)
|
||||
{
|
||||
if ($connection instanceof \Redis || $connection instanceof \RedisArray || $connection instanceof \RedisCluster || $connection instanceof \Predis\Client || $connection instanceof RedisProxy) {
|
||||
if ($connection instanceof \Redis || $connection instanceof \RedisArray || $connection instanceof \RedisCluster || $connection instanceof \Predis\ClientInterface || $connection instanceof RedisProxy) {
|
||||
return new RedisStore($connection);
|
||||
}
|
||||
if ($connection instanceof \Memcached) {
|
||||
|
@ -31,7 +31,7 @@ abstract class AbstractRedisStoreTest extends AbstractStoreTest
|
||||
/**
|
||||
* Return a RedisConnection.
|
||||
*
|
||||
* @return \Redis|\RedisArray|\RedisCluster|\Predis\Client
|
||||
* @return \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface
|
||||
*/
|
||||
abstract protected function getRedisConnection();
|
||||
|
||||
|
Reference in New Issue
Block a user