Predis to v2.2.2

This commit is contained in:
the-djmaze 2024-04-02 20:15:23 +02:00
parent f6b440adef
commit 84ffe1e552
259 changed files with 2407 additions and 9937 deletions

View file

@ -3,7 +3,8 @@
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -11,30 +12,31 @@
namespace Predis\Pipeline;
use Exception;
use InvalidArgumentException;
use Predis\ClientContextInterface;
use Predis\ClientException;
use Predis\ClientInterface;
use Predis\Command\CommandInterface;
use Predis\Connection\Aggregate\ReplicationInterface;
use Predis\Connection\ConnectionInterface;
use Predis\Connection\Replication\ReplicationInterface;
use Predis\Response\ErrorInterface as ErrorResponseInterface;
use Predis\Response\ResponseInterface;
use Predis\Response\ServerException;
use SplQueue;
/**
* Implementation of a command pipeline in which write and read operations of
* Redis commands are pipelined to alleviate the effects of network round-trips.
*
* {@inheritdoc}
*
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
class Pipeline implements ClientContextInterface
{
private $client;
protected $client;
private $pipeline;
private $responses = array();
private $responses = [];
private $running = false;
/**
@ -43,7 +45,7 @@ class Pipeline implements ClientContextInterface
public function __construct(ClientInterface $client)
{
$this->client = $client;
$this->pipeline = new \SplQueue();
$this->pipeline = new SplQueue();
}
/**
@ -112,7 +114,7 @@ class Pipeline implements ClientContextInterface
$connection = $this->getClient()->getConnection();
if ($connection instanceof ReplicationInterface) {
$connection->switchTo('master');
$connection->switchToMaster();
}
return $connection;
@ -123,17 +125,17 @@ class Pipeline implements ClientContextInterface
* from the current connection.
*
* @param ConnectionInterface $connection Current connection instance.
* @param \SplQueue $commands Queued commands.
* @param SplQueue $commands Queued commands.
*
* @return array
*/
protected function executePipeline(ConnectionInterface $connection, \SplQueue $commands)
protected function executePipeline(ConnectionInterface $connection, SplQueue $commands)
{
foreach ($commands as $command) {
$connection->writeRequest($command);
}
$responses = array();
$responses = [];
$exceptions = $this->throwServerExceptions();
while (!$commands->isEmpty()) {
@ -165,7 +167,7 @@ class Pipeline implements ClientContextInterface
$responses = $this->executePipeline($this->getConnection(), $this->pipeline);
$this->responses = array_merge($this->responses, $responses);
} else {
$this->pipeline = new \SplQueue();
$this->pipeline = new SplQueue();
}
return $this;
@ -192,15 +194,14 @@ class Pipeline implements ClientContextInterface
*
* @param mixed $callable Optional callback for execution.
*
* @throws \Exception
* @throws \InvalidArgumentException
*
* @return array
* @throws Exception
* @throws InvalidArgumentException
*/
public function execute($callable = null)
{
if ($callable && !is_callable($callable)) {
throw new \InvalidArgumentException('The argument must be a callable object.');
throw new InvalidArgumentException('The argument must be a callable object.');
}
$exception = null;
@ -212,7 +213,7 @@ class Pipeline implements ClientContextInterface
}
$this->flushPipeline();
} catch (\Exception $exception) {
} catch (Exception $exception) {
// NOOP
}