minor #33666 [Lock] use Predis\ClientInterface instead of Predis\Client (seferov)
This PR was squashed before being merged into the 3.4 branch (closes #33666).
Discussion
----------
[Lock] use Predis\ClientInterface instead of Predis\Client
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| License | MIT
`\Predis\ClientInterface` can be used instead of `\Predis\Client` for RedisStore.
Commits
-------
5c01f0a7e5
[Lock] use Predis\ClientInterface instead of Predis\Client
This commit is contained in:
commit
35b670112c
@ -31,13 +31,13 @@ class RedisStore implements StoreInterface
|
|||||||
private $initialTtl;
|
private $initialTtl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
|
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
|
||||||
* @param float $initialTtl the expiration delay of locks in seconds
|
* @param float $initialTtl the expiration delay of locks in seconds
|
||||||
*/
|
*/
|
||||||
public function __construct($redisClient, $initialTtl = 300.0)
|
public function __construct($redisClient, $initialTtl = 300.0)
|
||||||
{
|
{
|
||||||
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\Client && !$redisClient instanceof RedisProxy) {
|
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\Client, %s given', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient)));
|
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) {
|
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);
|
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));
|
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
|
class StoreFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|\Memcached $connection
|
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|\Memcached $connection
|
||||||
*
|
*
|
||||||
* @return RedisStore|MemcachedStore
|
* @return RedisStore|MemcachedStore
|
||||||
*/
|
*/
|
||||||
public static function createStore($connection)
|
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);
|
return new RedisStore($connection);
|
||||||
}
|
}
|
||||||
if ($connection instanceof \Memcached) {
|
if ($connection instanceof \Memcached) {
|
||||||
|
@ -31,7 +31,7 @@ abstract class AbstractRedisStoreTest extends AbstractStoreTest
|
|||||||
/**
|
/**
|
||||||
* Return a RedisConnection.
|
* Return a RedisConnection.
|
||||||
*
|
*
|
||||||
* @return \Redis|\RedisArray|\RedisCluster|\Predis\Client
|
* @return \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface
|
||||||
*/
|
*/
|
||||||
abstract protected function getRedisConnection();
|
abstract protected function getRedisConnection();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user