mirror of
https://github.com/predis/predis.git
synced 2026-08-20 06:51:50 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 18de796a0c | |||
| 5993a9bf6c | |||
| 3fdbcfca24 | |||
| 59668bee77 | |||
| 44e4546ccd | |||
| da7b1cedb7 | |||
| fd1a0fc278 | |||
| 7a15da293b | |||
| d9dfefd247 | |||
| 8a0c70baa5 | |||
| 053cb4b6ac | |||
| 0f4bc7653c |
@@ -1,7 +1,7 @@
|
||||
name-template: 'v$NEXT_MINOR_VERSION'
|
||||
tag-template: 'v$NEXT_MINOR_VERSION'
|
||||
change-template: '- $TITLE (#$NUMBER)'
|
||||
filter-by-comitish: true
|
||||
filter-by-commitish: true
|
||||
commitish: v3.x
|
||||
|
||||
autolabeler:
|
||||
|
||||
@@ -32,6 +32,7 @@ jobs:
|
||||
- '7.4'
|
||||
- '8.0'
|
||||
- '8.2'
|
||||
- '8.4'
|
||||
|
||||
steps:
|
||||
|
||||
@@ -39,7 +40,8 @@ jobs:
|
||||
run: |
|
||||
# Mapping of original redis versions to client test containers
|
||||
declare -A redis_clients_version_mapping=(
|
||||
["8.2"]="8.2"
|
||||
["8.4"]="8.4-M01-pre"
|
||||
["8.2"]="8.2.2-pre"
|
||||
["8.0"]="8.0.2"
|
||||
["7.4"]="7.4.2"
|
||||
["7.2"]="7.2.7"
|
||||
@@ -107,7 +109,7 @@ jobs:
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: relay
|
||||
extensions: relay-0.12.0
|
||||
coverage: ${{ (matrix.php == '8.4' && matrix.redis == '8.0') && 'xdebug' || 'none' }}
|
||||
|
||||
- name: Install Composer dependencies
|
||||
|
||||
@@ -2,8 +2,15 @@
|
||||
|
||||
## Unreleased
|
||||
### Added
|
||||
- Added cluster support for `XADD`, `XDEL` and `XRANGE` (#1587)
|
||||
- Added prefixable interface for `HEXPIRE` and `HEXPIRETIME` (#1592)
|
||||
|
||||
### Changed
|
||||
- Refactor pipeline data writing depends on connection type (#1586)
|
||||
- Improved compatiblity with Relay (#1597)
|
||||
|
||||
### Maintenance
|
||||
- Added testing with 8.4-M01 (#1593)
|
||||
|
||||
## v3.2.0 (2025-08-05)
|
||||
### Added
|
||||
|
||||
@@ -34,11 +34,11 @@ class SimpleDebuggableConnection extends StreamConnection
|
||||
|
||||
private function storeDebug(CommandInterface $command, $direction)
|
||||
{
|
||||
$firtsArg = $command->getArgument(0);
|
||||
$firstArg = $command->getArgument(0);
|
||||
$timestamp = round(microtime(true) - $this->tstart, 4);
|
||||
|
||||
$debug = $command->getId();
|
||||
$debug .= isset($firtsArg) ? " $firtsArg " : ' ';
|
||||
$debug .= isset($firstArg) ? " $firstArg " : ' ';
|
||||
$debug .= "$direction $this";
|
||||
$debug .= " [{$timestamp}s]";
|
||||
|
||||
|
||||
@@ -155,6 +155,11 @@ abstract class ClusterStrategy implements StrategyInterface
|
||||
'HSCAN' => $getKeyFromFirstArgument,
|
||||
'HSTRLEN' => $getKeyFromFirstArgument,
|
||||
|
||||
/* commands operating on streams */
|
||||
'XADD' => $getKeyFromFirstArgument,
|
||||
'XDEL' => $getKeyFromFirstArgument,
|
||||
'XRANGE' => $getKeyFromFirstArgument,
|
||||
|
||||
/* commands operating on HyperLogLog */
|
||||
'PFADD' => $getKeyFromFirstArgument,
|
||||
'PFCOUNT' => $getKeyFromAllArguments,
|
||||
|
||||
@@ -32,9 +32,23 @@ class COMMAND extends BaseCommand
|
||||
*/
|
||||
public function parseResponse($data)
|
||||
{
|
||||
// Relay (RESP3) uses maps and it might be good
|
||||
// to make the return value a breaking change
|
||||
if (!is_array($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return $data;
|
||||
if ($data === array_values($data)) {
|
||||
return array_map(function ($item) {
|
||||
return $this->parseResponse($item);
|
||||
}, $data);
|
||||
}
|
||||
|
||||
// Relay
|
||||
$result = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$result[] = $key;
|
||||
$result[] = $this->parseResponse($value);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,4 +127,26 @@ class FUNCTIONS extends RedisCommand
|
||||
|
||||
parent::setArguments($processedArguments);
|
||||
}
|
||||
|
||||
public function parseResponse($data)
|
||||
{
|
||||
if (!is_array($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
if ($data === array_values($data)) {
|
||||
return array_map(function ($item) {
|
||||
return $this->parseResponse($item);
|
||||
}, $data);
|
||||
}
|
||||
|
||||
// Relay
|
||||
$result = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$result[] = $key;
|
||||
$result[] = $this->parseResponse($value);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace Predis\Command\Redis;
|
||||
|
||||
use Predis\Command\Command as RedisCommand;
|
||||
use Predis\Command\PrefixableCommand as RedisCommand;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class HEXPIRE extends RedisCommand
|
||||
@@ -48,4 +48,9 @@ class HEXPIRE extends RedisCommand
|
||||
|
||||
parent::setArguments($processedArguments);
|
||||
}
|
||||
|
||||
public function prefixKeys($prefix)
|
||||
{
|
||||
$this->applyPrefixForFirstArgument($prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace Predis\Command\Redis;
|
||||
|
||||
use Predis\Command\Command as RedisCommand;
|
||||
use Predis\Command\PrefixableCommand as RedisCommand;
|
||||
|
||||
class HEXPIRETIME extends RedisCommand
|
||||
{
|
||||
@@ -28,4 +28,9 @@ class HEXPIRETIME extends RedisCommand
|
||||
|
||||
parent::setArguments($processedArguments);
|
||||
}
|
||||
|
||||
public function prefixKeys($prefix)
|
||||
{
|
||||
$this->applyPrefixForFirstArgument($prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,20 @@ class FTCONFIG extends RedisCommand
|
||||
{
|
||||
return 'FT.CONFIG';
|
||||
}
|
||||
|
||||
public function parseResponse($data)
|
||||
{
|
||||
if (!is_array($data) || $data === array_values($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Relay
|
||||
$result = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$group = [$key, $value];
|
||||
$result[] = $group;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,11 @@ class VINFO extends RedisCommand
|
||||
public function parseResponse($data): ?array
|
||||
{
|
||||
if (!is_null($data)) {
|
||||
return CommandUtility::arrayToDictionary($data);
|
||||
if ($data === array_values($data)) {
|
||||
return CommandUtility::arrayToDictionary($data);
|
||||
} else {
|
||||
return $data; // Relay
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
@@ -84,9 +84,11 @@ class VSIM extends RedisCommand
|
||||
public function parseResponse($data)
|
||||
{
|
||||
if ($this->withScores) {
|
||||
$data = CommandUtility::arrayToDictionary($data, function ($key, $value) {
|
||||
return [$key, (float) $value];
|
||||
});
|
||||
if ($data === array_values($data)) {
|
||||
$data = CommandUtility::arrayToDictionary($data, function ($key, $value) {
|
||||
return [$key, (float) $value];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
@@ -58,7 +58,11 @@ class XINFO extends RedisCommand
|
||||
|
||||
private function parseStreamResponse($data): array
|
||||
{
|
||||
$result = CommandUtility::arrayToDictionary($data, null, false);
|
||||
if ($data === array_values($data)) {
|
||||
$result = CommandUtility::arrayToDictionary($data, null, false);
|
||||
} else {
|
||||
$result = $data; // Relay
|
||||
}
|
||||
|
||||
if (isset($result['entries'])) {
|
||||
$result['entries'] = $this->parseDict($result['entries']);
|
||||
@@ -66,10 +70,16 @@ class XINFO extends RedisCommand
|
||||
|
||||
if (isset($result['groups']) && is_array($result['groups'])) {
|
||||
$result['groups'] = array_map(static function ($group) {
|
||||
$group = CommandUtility::arrayToDictionary($group, null, false);
|
||||
if ($group === array_values($group)) {
|
||||
$group = CommandUtility::arrayToDictionary($group, null, false);
|
||||
}
|
||||
if (isset($group['consumers'])) {
|
||||
$group['consumers'] = array_map(static function ($consumer) {
|
||||
return CommandUtility::arrayToDictionary($consumer, null, false);
|
||||
if ($consumer === array_values($consumer)) {
|
||||
$consumer = CommandUtility::arrayToDictionary($consumer, null, false);
|
||||
}
|
||||
|
||||
return $consumer;
|
||||
}, $group['consumers']);
|
||||
}
|
||||
|
||||
@@ -92,6 +102,10 @@ class XINFO extends RedisCommand
|
||||
|
||||
private function parseDict($data): array
|
||||
{
|
||||
if ($data !== array_values($data)) {
|
||||
return $data; // Relay
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
for ($i = 0, $iMax = count($data); $i < $iMax; $i++) {
|
||||
|
||||
@@ -50,6 +50,10 @@ class XREAD extends RedisCommand
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($data !== array_values($data)) {
|
||||
return $data; // Relay
|
||||
}
|
||||
|
||||
$processedData = [];
|
||||
|
||||
foreach ($data as $stream) {
|
||||
|
||||
@@ -42,4 +42,20 @@ class XREADGROUP extends RedisCommand
|
||||
|
||||
parent::setArguments(array_merge($processedArguments, $keyOrIds));
|
||||
}
|
||||
|
||||
public function parseResponse($data)
|
||||
{
|
||||
if (!is_array($data) || $data === array_values($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Relay
|
||||
$result = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$group = [$key, $value];
|
||||
$result[] = $group;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Predis\Pipeline;
|
||||
|
||||
use Predis\ClientException;
|
||||
use Predis\ClientInterface;
|
||||
use Predis\Connection\AggregateConnectionInterface;
|
||||
use Predis\Connection\ConnectionInterface;
|
||||
use Predis\Connection\NodeConnectionInterface;
|
||||
use Predis\Response\ErrorInterface as ErrorResponseInterface;
|
||||
@@ -63,14 +64,13 @@ class Atomic extends Pipeline
|
||||
{
|
||||
$commandFactory = $this->getClient()->getCommandFactory();
|
||||
$connection->executeCommand($commandFactory->create('multi'));
|
||||
$buffer = '';
|
||||
|
||||
foreach ($commands as $command) {
|
||||
$buffer .= $command->serializeCommand();
|
||||
if ($connection instanceof AggregateConnectionInterface) {
|
||||
$this->writeToMultiNode($connection, $commands);
|
||||
} else {
|
||||
$this->writeToSingleNode($connection, $commands);
|
||||
}
|
||||
|
||||
$connection->write($buffer);
|
||||
|
||||
foreach ($commands as $command) {
|
||||
$response = $connection->readResponse($command);
|
||||
|
||||
|
||||
@@ -92,14 +92,12 @@ class ConnectionErrorProof extends Pipeline
|
||||
$responses = [];
|
||||
$sizeOfPipe = count($commands);
|
||||
$exceptions = [];
|
||||
$buffer = '';
|
||||
|
||||
foreach ($commands as $command) {
|
||||
$buffer .= $command->serializeCommand();
|
||||
$nodeConnection = $connection->getConnectionByCommand($command);
|
||||
$nodeConnection->write($command->serializeCommand());
|
||||
}
|
||||
|
||||
$connection->write($buffer);
|
||||
|
||||
for ($i = 0; $i < $sizeOfPipe; ++$i) {
|
||||
$command = $commands->dequeue();
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace Predis\Pipeline;
|
||||
|
||||
use Predis\Connection\AggregateConnectionInterface;
|
||||
use Predis\Connection\ConnectionInterface;
|
||||
use SplQueue;
|
||||
|
||||
@@ -25,13 +26,12 @@ class FireAndForget extends Pipeline
|
||||
*/
|
||||
protected function executePipeline(ConnectionInterface $connection, SplQueue $commands)
|
||||
{
|
||||
$buffer = '';
|
||||
|
||||
while (!$commands->isEmpty()) {
|
||||
$buffer .= $commands->dequeue()->serializeCommand();
|
||||
if ($connection instanceof AggregateConnectionInterface) {
|
||||
$this->writeToMultiNode($connection, $commands);
|
||||
} else {
|
||||
$this->writeToSingleNode($connection, $commands);
|
||||
}
|
||||
|
||||
$connection->write($buffer);
|
||||
$connection->disconnect();
|
||||
|
||||
return [];
|
||||
|
||||
@@ -18,6 +18,7 @@ use Predis\ClientContextInterface;
|
||||
use Predis\ClientException;
|
||||
use Predis\ClientInterface;
|
||||
use Predis\Command\CommandInterface;
|
||||
use Predis\Connection\AggregateConnectionInterface;
|
||||
use Predis\Connection\ConnectionInterface;
|
||||
use Predis\Connection\Replication\ReplicationInterface;
|
||||
use Predis\Response\ErrorInterface as ErrorResponseInterface;
|
||||
@@ -131,14 +132,12 @@ class Pipeline implements ClientContextInterface
|
||||
*/
|
||||
protected function executePipeline(ConnectionInterface $connection, SplQueue $commands)
|
||||
{
|
||||
$buffer = '';
|
||||
|
||||
foreach ($commands as $command) {
|
||||
$buffer .= $command->serializeCommand();
|
||||
if ($connection instanceof AggregateConnectionInterface) {
|
||||
$this->writeToMultiNode($connection, $commands);
|
||||
} else {
|
||||
$this->writeToSingleNode($connection, $commands);
|
||||
}
|
||||
|
||||
$connection->write($buffer);
|
||||
|
||||
$responses = [];
|
||||
$exceptions = $this->throwServerExceptions();
|
||||
$protocolVersion = (int) $connection->getParameters()->protocol;
|
||||
@@ -163,6 +162,39 @@ class Pipeline implements ClientContextInterface
|
||||
return $responses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes pipelined commands to single node connection.
|
||||
*
|
||||
* @param ConnectionInterface $connection
|
||||
* @param SplQueue $commands
|
||||
* @return void
|
||||
*/
|
||||
protected function writeToSingleNode(ConnectionInterface $connection, SplQueue $commands)
|
||||
{
|
||||
$buffer = '';
|
||||
|
||||
foreach ($commands as $command) {
|
||||
$buffer .= $command->serializeCommand();
|
||||
}
|
||||
|
||||
$connection->write($buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes pipelined commands to multi node connection.
|
||||
*
|
||||
* @param AggregateConnectionInterface $connection
|
||||
* @param SplQueue $commands
|
||||
* @return void
|
||||
*/
|
||||
protected function writeToMultiNode(AggregateConnectionInterface $connection, SplQueue $commands)
|
||||
{
|
||||
foreach ($commands as $command) {
|
||||
$nodeConnection = $connection->getConnectionByCommand($command);
|
||||
$nodeConnection->write($command->serializeCommand());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes the buffer holding all of the commands queued so far.
|
||||
*
|
||||
|
||||
@@ -474,6 +474,11 @@ class PredisStrategyTest extends PredisTestCase
|
||||
'HSCAN' => 'keys-first',
|
||||
'HSTRLEN' => 'keys-first',
|
||||
|
||||
/* commands operating on streams */
|
||||
'XADD' => 'keys-first',
|
||||
'XDEL' => 'keys-first',
|
||||
'XRANGE' => 'keys-first',
|
||||
|
||||
/* commands operating on HyperLogLog */
|
||||
'PFADD' => 'keys-first',
|
||||
'PFCOUNT' => 'keys-all',
|
||||
|
||||
@@ -497,6 +497,11 @@ class RedisStrategyTest extends PredisTestCase
|
||||
'HSCAN' => 'keys-first',
|
||||
'HSTRLEN' => 'keys-first',
|
||||
|
||||
/* commands operating on streams */
|
||||
'XADD' => 'keys-first',
|
||||
'XDEL' => 'keys-first',
|
||||
'XRANGE' => 'keys-first',
|
||||
|
||||
/* commands operating on HyperLogLog */
|
||||
'PFADD' => 'keys-first',
|
||||
'PFCOUNT' => 'keys-all',
|
||||
|
||||
@@ -13,13 +13,23 @@
|
||||
namespace Predis\Command\Processor;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Predis\ClientException;
|
||||
use Predis\Command\CommandInterface;
|
||||
use Predis\Command\RawCommand;
|
||||
use Predis\Command\RedisFactory;
|
||||
use PredisTestCase;
|
||||
use stdClass;
|
||||
|
||||
class KeyPrefixProcessorTest extends PredisTestCase
|
||||
{
|
||||
/** @var RedisFactory */
|
||||
private $commandsFactory;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->commandsFactory = new RedisFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
@@ -175,6 +185,25 @@ class KeyPrefixProcessorTest extends PredisTestCase
|
||||
$processor->setCommandHandler('NEWCMD', new stdClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
* @dataProvider commandArgumentsDataProvider
|
||||
*
|
||||
* @param string $commandID
|
||||
* @param array $arguments
|
||||
* @param array $expected
|
||||
* @throws ClientException
|
||||
*/
|
||||
public function testApplyPrefixToCommand($commandID, array $arguments, array $expected): void
|
||||
{
|
||||
$processor = new KeyPrefixProcessor('prefix:');
|
||||
$command = $this->commandsFactory->create($commandID, $arguments);
|
||||
|
||||
$processor->process($command);
|
||||
|
||||
$this->assertSame($expected, $command->getArguments());
|
||||
}
|
||||
|
||||
// ******************************************************************** //
|
||||
// ---- HELPER METHODS ------------------------------------------------ //
|
||||
// ******************************************************************** //
|
||||
@@ -194,4 +223,622 @@ class KeyPrefixProcessorTest extends PredisTestCase
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for key prefixing test.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function commandArgumentsDataProvider(): array
|
||||
{
|
||||
return [
|
||||
/* ---------------- Redis 1.2 ---------------- */
|
||||
['EXISTS',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['DEL',
|
||||
['key1', 'key2', 'key3'],
|
||||
['prefix:key1', 'prefix:key2', 'prefix:key3'],
|
||||
],
|
||||
['TYPE',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['KEYS',
|
||||
['pattern'],
|
||||
['prefix:pattern'],
|
||||
],
|
||||
['RENAME',
|
||||
['key', 'newkey'],
|
||||
['prefix:key', 'prefix:newkey'],
|
||||
],
|
||||
['RENAMENX',
|
||||
['key', 'newkey'],
|
||||
['prefix:key', 'prefix:newkey'],
|
||||
],
|
||||
['EXPIRE',
|
||||
['key', 'value'],
|
||||
['prefix:key', 'value'],
|
||||
],
|
||||
['EXPIREAT',
|
||||
['key', 'value'],
|
||||
['prefix:key', 'value'],
|
||||
],
|
||||
['TTL',
|
||||
['key', 10],
|
||||
['prefix:key', 10],
|
||||
],
|
||||
['MOVE',
|
||||
['key', 'db'],
|
||||
['prefix:key', 'db'],
|
||||
],
|
||||
['SORT',
|
||||
['key', ['by' => 'by_key_*', 'get' => ['object_*', '#'], 'limit' => [1, 4], 'sort' => 'asc', 'alpha' => true, 'store' => 'destination_key']],
|
||||
['prefix:key', 'BY', 'prefix:by_key_*', 'GET', 'prefix:object_*', 'GET', '#', 'LIMIT', 1, 4, 'ASC', 'ALPHA', 'STORE', 'prefix:destination_key'],
|
||||
],
|
||||
['DUMP',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['RESTORE',
|
||||
['key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("],
|
||||
['prefix:key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("],
|
||||
],
|
||||
['SET',
|
||||
['key', 'value'],
|
||||
['prefix:key', 'value'],
|
||||
],
|
||||
['SET',
|
||||
['key', 'value', 'EX', 10, 'NX'],
|
||||
['prefix:key', 'value', 'EX', 10, 'NX'],
|
||||
],
|
||||
['SETNX',
|
||||
['key', 'value'],
|
||||
['prefix:key', 'value'],
|
||||
],
|
||||
['MSET',
|
||||
['foo', 'bar', 'hoge', 'piyo'],
|
||||
['prefix:foo', 'bar', 'prefix:hoge', 'piyo'],
|
||||
],
|
||||
['MSETNX',
|
||||
['foo', 'bar', 'hoge', 'piyo'],
|
||||
['prefix:foo', 'bar', 'prefix:hoge', 'piyo'],
|
||||
],
|
||||
['GET',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['MGET',
|
||||
['key1', 'key2', 'key3'],
|
||||
['prefix:key1', 'prefix:key2', 'prefix:key3'],
|
||||
],
|
||||
['GETSET',
|
||||
['key', 'value'],
|
||||
['prefix:key', 'value'],
|
||||
],
|
||||
['INCR',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['INCRBY',
|
||||
['key', 5],
|
||||
['prefix:key', 5],
|
||||
],
|
||||
['DECR',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['DECRBY',
|
||||
['key', 5],
|
||||
['prefix:key', 5],
|
||||
],
|
||||
['RPUSH',
|
||||
['key', 'value1', 'value2', 'value3'],
|
||||
['prefix:key', 'value1', 'value2', 'value3'],
|
||||
],
|
||||
['LPUSH',
|
||||
['key', 'value1', 'value2', 'value3'],
|
||||
['prefix:key', 'value1', 'value2', 'value3'],
|
||||
],
|
||||
['LLEN',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['LRANGE',
|
||||
['key', 0, -1],
|
||||
['prefix:key', 0, -1],
|
||||
],
|
||||
['LTRIM',
|
||||
['key', 0, 1],
|
||||
['prefix:key', 0, 1],
|
||||
],
|
||||
['LINDEX',
|
||||
['key', 1],
|
||||
['prefix:key', 1],
|
||||
],
|
||||
['LSET',
|
||||
['key', 0, 'value'],
|
||||
['prefix:key', 0, 'value'],
|
||||
],
|
||||
['LREM',
|
||||
['key', 0, 'value'],
|
||||
['prefix:key', 0, 'value'],
|
||||
],
|
||||
['LPOP',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['RPOP',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['RPOPLPUSH',
|
||||
['key:source', 'key:destination'],
|
||||
['prefix:key:source', 'prefix:key:destination'],
|
||||
],
|
||||
['SADD',
|
||||
['key', 'member1', 'member2', 'member3'],
|
||||
['prefix:key', 'member1', 'member2', 'member3'],
|
||||
],
|
||||
['SREM',
|
||||
['key', 'member1', 'member2', 'member3'],
|
||||
['prefix:key', 'member1', 'member2', 'member3'],
|
||||
],
|
||||
['SPOP',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['SMOVE',
|
||||
['key:source', 'key:destination', 'member'],
|
||||
['prefix:key:source', 'prefix:key:destination', 'member'],
|
||||
],
|
||||
['SCARD',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['SISMEMBER',
|
||||
['key', 'member'],
|
||||
['prefix:key', 'member'],
|
||||
],
|
||||
['SINTER',
|
||||
['key1', 'key2', 'key3'],
|
||||
['prefix:key1', 'prefix:key2', 'prefix:key3'],
|
||||
],
|
||||
['SINTERSTORE',
|
||||
['key:destination', 'key1', 'key2'],
|
||||
['prefix:key:destination', 'prefix:key1', 'prefix:key2'],
|
||||
],
|
||||
['SUNION',
|
||||
['key1', 'key2', 'key3'],
|
||||
['prefix:key1', 'prefix:key2', 'prefix:key3'],
|
||||
],
|
||||
['SUNIONSTORE',
|
||||
['key:destination', 'key1', 'key2'],
|
||||
['prefix:key:destination', 'prefix:key1', 'prefix:key2'],
|
||||
],
|
||||
['SDIFF',
|
||||
['key1', 'key2', 'key3'],
|
||||
['prefix:key1', 'prefix:key2', 'prefix:key3'],
|
||||
],
|
||||
['SDIFFSTORE',
|
||||
['key:destination', 'key1', 'key2'],
|
||||
['prefix:key:destination', 'prefix:key1', 'prefix:key2'],
|
||||
],
|
||||
['SMEMBERS',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['SMISMEMBER',
|
||||
['key', 'member1', 'member2', 'member3'],
|
||||
['prefix:key', 'member1', 'member2', 'member3'],
|
||||
],
|
||||
['SRANDMEMBER',
|
||||
['key', 1],
|
||||
['prefix:key', 1],
|
||||
],
|
||||
['ZADD',
|
||||
['key', 'score1', 'member1', 'score2', 'member2'],
|
||||
['prefix:key', 'score1', 'member1', 'score2', 'member2'],
|
||||
],
|
||||
['ZINCRBY',
|
||||
['key', 1.0, 'member'],
|
||||
['prefix:key', 1.0, 'member'],
|
||||
],
|
||||
['ZREM',
|
||||
['key', 'member1', 'member2', 'member3'],
|
||||
['prefix:key', 'member1', 'member2', 'member3'],
|
||||
],
|
||||
['ZRANGE',
|
||||
['key', 0, 100, 'WITHSCORES'],
|
||||
['prefix:key', 0, 100, 'WITHSCORES'],
|
||||
],
|
||||
['ZREVRANGE',
|
||||
['key', 0, 100, 'WITHSCORES'],
|
||||
['prefix:key', 0, 100, 'WITHSCORES'],
|
||||
],
|
||||
['ZRANGEBYSCORE',
|
||||
['key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'],
|
||||
['prefix:key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'],
|
||||
],
|
||||
['ZCARD',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['ZSCORE',
|
||||
['key', 'member'],
|
||||
['prefix:key', 'member'],
|
||||
],
|
||||
['ZREMRANGEBYSCORE',
|
||||
['key', 0, 10],
|
||||
['prefix:key', 0, 10],
|
||||
],
|
||||
/* ---------------- Redis 2.0 ---------------- */
|
||||
['SETEX',
|
||||
['key', 10, 'value'],
|
||||
['prefix:key', 10, 'value'],
|
||||
],
|
||||
['APPEND',
|
||||
['key', 'value'],
|
||||
['prefix:key', 'value'],
|
||||
],
|
||||
['SUBSTR',
|
||||
['key', 5, 10],
|
||||
['prefix:key', 5, 10],
|
||||
],
|
||||
['BLPOP',
|
||||
['key1', 'key2', 'key3', 10],
|
||||
['prefix:key1', 'prefix:key2', 'prefix:key3', 10],
|
||||
],
|
||||
['BRPOP',
|
||||
['key1', 'key2', 'key3', 10],
|
||||
['prefix:key1', 'prefix:key2', 'prefix:key3', 10],
|
||||
],
|
||||
['ZUNIONSTORE',
|
||||
['key:destination', ['key1', 'key2']],
|
||||
['prefix:key:destination', 2, 'prefix:key1', 'prefix:key2'],
|
||||
],
|
||||
['ZINTERSTORE',
|
||||
['key:destination', ['key1', 'key2']],
|
||||
['prefix:key:destination', 2, 'prefix:key1', 'prefix:key2'],
|
||||
],
|
||||
['ZCOUNT',
|
||||
['key', 0, 10],
|
||||
['prefix:key', 0, 10],
|
||||
],
|
||||
['ZRANK',
|
||||
['key', 'member'],
|
||||
['prefix:key', 'member'],
|
||||
],
|
||||
['ZREVRANK',
|
||||
['key', 'member'],
|
||||
['prefix:key', 'member'],
|
||||
],
|
||||
['ZREMRANGEBYRANK',
|
||||
['key', 0, 10],
|
||||
['prefix:key', 0, 10],
|
||||
],
|
||||
['HSET',
|
||||
['key', 'field', 'value'],
|
||||
['prefix:key', 'field', 'value'],
|
||||
],
|
||||
['HSETNX',
|
||||
['key', 'field', 'value'],
|
||||
['prefix:key', 'field', 'value'],
|
||||
],
|
||||
['HMSET',
|
||||
['key', 'field1', 'value1', 'field2', 'value2'],
|
||||
['prefix:key', 'field1', 'value1', 'field2', 'value2'],
|
||||
],
|
||||
['HINCRBY',
|
||||
['key', 'field', 10],
|
||||
['prefix:key', 'field', 10],
|
||||
],
|
||||
['HGET',
|
||||
['key', 'field'],
|
||||
['prefix:key', 'field'],
|
||||
],
|
||||
['HMGET',
|
||||
['key', 'field1', 'field2', 'field3'],
|
||||
['prefix:key', 'field1', 'field2', 'field3'],
|
||||
],
|
||||
['HDEL',
|
||||
['key', 'field1', 'field2', 'field3'],
|
||||
['prefix:key', 'field1', 'field2', 'field3'],
|
||||
],
|
||||
['HEXISTS',
|
||||
['key', 'field'],
|
||||
['prefix:key', 'field'],
|
||||
],
|
||||
['HLEN',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['HKEYS',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['HVALS',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['HGETALL',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['SUBSCRIBE',
|
||||
['channel:foo', 'channel:hoge'],
|
||||
['prefix:channel:foo', 'prefix:channel:hoge'],
|
||||
],
|
||||
['UNSUBSCRIBE',
|
||||
['channel:foo', 'channel:hoge'],
|
||||
['prefix:channel:foo', 'prefix:channel:hoge'],
|
||||
],
|
||||
['PSUBSCRIBE',
|
||||
['channel:foo:*', 'channel:hoge:*'],
|
||||
['prefix:channel:foo:*', 'prefix:channel:hoge:*'],
|
||||
],
|
||||
['PUNSUBSCRIBE',
|
||||
['channel:foo:*', 'channel:hoge:*'],
|
||||
['prefix:channel:foo:*', 'prefix:channel:hoge:*'],
|
||||
],
|
||||
['PUBLISH',
|
||||
['channel', 'message'],
|
||||
['prefix:channel', 'message'],
|
||||
],
|
||||
/* ---------------- Redis 2.2 ---------------- */
|
||||
['PERSIST',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['STRLEN',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['SETRANGE',
|
||||
['key', 5, 'string'],
|
||||
['prefix:key', 5, 'string'],
|
||||
],
|
||||
['GETRANGE',
|
||||
['key', 5, 10],
|
||||
['prefix:key', 5, 10],
|
||||
],
|
||||
['SETBIT',
|
||||
['key', 7, 1],
|
||||
['prefix:key', 7, 1],
|
||||
],
|
||||
['GETBIT',
|
||||
['key', 100],
|
||||
['prefix:key', 100],
|
||||
],
|
||||
['RPUSHX',
|
||||
['key', 'value'],
|
||||
['prefix:key', 'value'],
|
||||
],
|
||||
['LPUSHX',
|
||||
['key', 'value'],
|
||||
['prefix:key', 'value'],
|
||||
],
|
||||
['LINSERT',
|
||||
['key', 'before', 'value1', 'value2'],
|
||||
['prefix:key', 'before', 'value1', 'value2'],
|
||||
],
|
||||
['BRPOPLPUSH',
|
||||
['key:source', 'key:destination', 10],
|
||||
['prefix:key:source', 'prefix:key:destination', 10],
|
||||
],
|
||||
['ZREVRANGEBYSCORE',
|
||||
['key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'],
|
||||
['prefix:key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'],
|
||||
],
|
||||
['WATCH',
|
||||
['key1', 'key2', 'key3'],
|
||||
['prefix:key1', 'prefix:key2', 'prefix:key3'],
|
||||
],
|
||||
/* ---------------- Redis 2.6 ---------------- */
|
||||
['PTTL',
|
||||
['key', 10],
|
||||
['prefix:key', 10],
|
||||
],
|
||||
['PEXPIRE',
|
||||
['key', 1500],
|
||||
['prefix:key', 1500],
|
||||
],
|
||||
['PEXPIREAT',
|
||||
['key', 1555555555005],
|
||||
['prefix:key', 1555555555005],
|
||||
],
|
||||
['PSETEX',
|
||||
['key', 1500, 'value'],
|
||||
['prefix:key', 1500, 'value'],
|
||||
],
|
||||
['INCRBYFLOAT',
|
||||
['key', 10.5],
|
||||
['prefix:key', 10.5],
|
||||
],
|
||||
['BITOP',
|
||||
['AND', 'key:dst', 'key:01', 'key:02'],
|
||||
['AND', 'prefix:key:dst', 'prefix:key:01', 'prefix:key:02'],
|
||||
],
|
||||
['BITCOUNT',
|
||||
['key', 0, 10],
|
||||
['prefix:key', 0, 10],
|
||||
],
|
||||
['HINCRBYFLOAT',
|
||||
['key', 'field', 10.5],
|
||||
['prefix:key', 'field', 10.5],
|
||||
],
|
||||
['EVAL',
|
||||
['return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'foo', 'hoge', 'bar', 'piyo'],
|
||||
['return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo'],
|
||||
],
|
||||
['EVALSHA',
|
||||
['a42059b356c875f0717db19a51f6aaca9ae659ea', 2, 'foo', 'hoge', 'bar', 'piyo'],
|
||||
['a42059b356c875f0717db19a51f6aaca9ae659ea', 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo'],
|
||||
],
|
||||
['BITPOS',
|
||||
['key', 0],
|
||||
['prefix:key', 0],
|
||||
],
|
||||
['MIGRATE',
|
||||
['127.0.0.1', '6379', 'key', '0', '10'],
|
||||
['127.0.0.1', '6379', 'prefix:key', '0', '10'],
|
||||
],
|
||||
/* ---------------- Redis 2.8 ---------------- */
|
||||
['SSCAN',
|
||||
['key', '0', 'MATCH', 'member:*', 'COUNT', 10],
|
||||
['prefix:key', '0', 'MATCH', 'member:*', 'COUNT', 10],
|
||||
],
|
||||
['ZSCAN',
|
||||
['key', '0', 'MATCH', 'member:*', 'COUNT', 10],
|
||||
['prefix:key', '0', 'MATCH', 'member:*', 'COUNT', 10],
|
||||
],
|
||||
['HSCAN',
|
||||
['key', '0', 'MATCH', 'field:*', 'COUNT', 10],
|
||||
['prefix:key', '0', 'MATCH', 'field:*', 'COUNT', 10],
|
||||
],
|
||||
['PFADD',
|
||||
['key', 'a', 'b', 'c'],
|
||||
['prefix:key', 'a', 'b', 'c'],
|
||||
],
|
||||
['PFCOUNT',
|
||||
['key:1', 'key:2', 'key:3'],
|
||||
['prefix:key:1', 'prefix:key:2', 'prefix:key:3'],
|
||||
],
|
||||
['PFMERGE',
|
||||
['key:1', 'key:2', 'key:3'],
|
||||
['prefix:key:1', 'prefix:key:2', 'prefix:key:3'],
|
||||
],
|
||||
['ZLEXCOUNT',
|
||||
['key', '-', '+'],
|
||||
['prefix:key', '-', '+'],
|
||||
],
|
||||
['ZRANGEBYLEX',
|
||||
['key', '-', '+', 'LIMIT', '0', '10'],
|
||||
['prefix:key', '-', '+', 'LIMIT', '0', '10'],
|
||||
],
|
||||
['ZREMRANGEBYLEX',
|
||||
['key', '-', '+'],
|
||||
['prefix:key', '-', '+'],
|
||||
],
|
||||
['ZREVRANGEBYLEX',
|
||||
['key', '+', '-', 'LIMIT', '0', '10'],
|
||||
['prefix:key', '+', '-', 'LIMIT', '0', '10'],
|
||||
],
|
||||
/* ---------------- Redis 3.0 ---------------- */
|
||||
['MIGRATE',
|
||||
['127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE'],
|
||||
['127.0.0.1', '6379', 'prefix:key', '0', '10', 'COPY', 'REPLACE'],
|
||||
],
|
||||
['EXISTS',
|
||||
['key1', 'key2', 'key3'],
|
||||
['prefix:key1', 'prefix:key2', 'prefix:key3'],
|
||||
],
|
||||
/* ---------------- Redis 3.2 ---------------- */
|
||||
['HSTRLEN',
|
||||
['key', 'field'],
|
||||
['prefix:key', 'field'],
|
||||
],
|
||||
['BITFIELD',
|
||||
['key', 'GET', 'u8', '0', 'SET', 'u8', '0', '1'],
|
||||
['prefix:key', 'GET', 'u8', '0', 'SET', 'u8', '0', '1'],
|
||||
],
|
||||
['GEOADD',
|
||||
['key', '13.361389', '38.115556', 'member:1', '15.087269', '37.502669', 'member:2'],
|
||||
['prefix:key', '13.361389', '38.115556', 'member:1', '15.087269', '37.502669', 'member:2'],
|
||||
],
|
||||
['GEOHASH',
|
||||
['key', 'member:1', 'member:2'],
|
||||
['prefix:key', 'member:1', 'member:2'],
|
||||
],
|
||||
['GEOPOS',
|
||||
['key', 'member:1', 'member:2'],
|
||||
['prefix:key', 'member:1', 'member:2'],
|
||||
],
|
||||
['GEODIST',
|
||||
['key', 'member:1', 'member:2', 'km'],
|
||||
['prefix:key', 'member:1', 'member:2', 'km'],
|
||||
],
|
||||
['GEORADIUS',
|
||||
['key', '15', '37', '200', 'km'],
|
||||
['prefix:key', '15', '37', '200', 'km'],
|
||||
],
|
||||
['GEORADIUS',
|
||||
['key', '15', '37', '200', 'km', 'WITHDIST', 'STORE', 'key:store', 'STOREDIST', 'key:storedist'],
|
||||
['prefix:key', '15', '37', '200', 'km', 'WITHDIST', 'STORE', 'prefix:key:store', 'STOREDIST', 'prefix:key:storedist'],
|
||||
],
|
||||
['GEORADIUSBYMEMBER',
|
||||
['key', 'member', '100', 'km'],
|
||||
['prefix:key', 'member', '100', 'km'],
|
||||
],
|
||||
['GEORADIUSBYMEMBER',
|
||||
['key', 'member', '100', 'km', 'WITHDIST', 'STORE', 'key:store', 'STOREDIST', 'key:storedist'],
|
||||
['prefix:key', 'member', '100', 'km', 'WITHDIST', 'STORE', 'prefix:key:store', 'STOREDIST', 'prefix:key:storedist'],
|
||||
],
|
||||
/* ---------------- Redis 5.0 ---------------- */
|
||||
['XADD',
|
||||
['key', ['field' => 'value']],
|
||||
['prefix:key', '*', 'field', 'value'],
|
||||
],
|
||||
['XRANGE',
|
||||
['key', '-', '+'],
|
||||
['prefix:key', '-', '+'],
|
||||
],
|
||||
['XREVRANGE',
|
||||
['key', '+', '-'],
|
||||
['prefix:key', '+', '-'],
|
||||
],
|
||||
['XDEL',
|
||||
['key', 'id'],
|
||||
['prefix:key', 'id'],
|
||||
],
|
||||
['XLEN',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['XACK',
|
||||
['key', 'group', 'id'],
|
||||
['prefix:key', 'group', 'id'],
|
||||
],
|
||||
['XTRIM',
|
||||
['key', 'MAXLEN', 100],
|
||||
['prefix:key', 'MAXLEN', 100],
|
||||
],
|
||||
['ZPOPMIN',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['ZPOPMAX',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
/* ---------------- Redis 6.2 ---------------- */
|
||||
['GETDEL',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
['LMOVE',
|
||||
['key:source', 'key:destination', 'left', 'right'],
|
||||
['prefix:key:source', 'prefix:key:destination', 'left', 'right'],
|
||||
],
|
||||
['BLMOVE',
|
||||
['key:source', 'key:destination', 'left', 'right', 10],
|
||||
['prefix:key:source', 'prefix:key:destination', 'left', 'right', 10],
|
||||
],
|
||||
/* ---------------- Redis 7.0 ---------------- */
|
||||
['EXPIRETIME',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
/* ---------------- Redis 7.4 ---------------- */
|
||||
['HEXPIRE',
|
||||
['key', 10, ['field1', 'field2']],
|
||||
['prefix:key', 10, 'FIELDS', 2, 'field1', 'field2'],
|
||||
],
|
||||
['HEXPIRETIME',
|
||||
['key', ['field1', 'field2']],
|
||||
['prefix:key', 'FIELDS', 2, 'field1', 'field2'],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class APPEND_Test extends PredisCommandTestCase
|
||||
* @group connected
|
||||
* @requiresRedisVersion >= 2.0.0
|
||||
*/
|
||||
public function testReturnsTheLenghtOfTheStringAfterAppend(): void
|
||||
public function testReturnsTheLengthOfTheStringAfterAppend(): void
|
||||
{
|
||||
$redis = $this->getClient();
|
||||
|
||||
|
||||
@@ -109,8 +109,6 @@ class COMMAND_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @requiresRedisVersion >= 2.8.13
|
||||
*
|
||||
* Relay uses RESP3 maps, the `Predis\Command\Redis\COMMAND` needs a converter.
|
||||
|
||||
@@ -173,7 +173,6 @@ class CONFIG_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @requiresRedisVersion >= 7.9.0
|
||||
*/
|
||||
public function testOverrideDefaultDialectWithConfigCommand()
|
||||
|
||||
@@ -327,7 +327,6 @@ class FUNCTIONS_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.0.0
|
||||
*/
|
||||
@@ -354,7 +353,6 @@ class FUNCTIONS_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.0.0
|
||||
*/
|
||||
|
||||
@@ -54,7 +54,6 @@ class HGETDEL_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
|
||||
@@ -78,7 +78,7 @@ class LINSERT_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
*/
|
||||
public function testReturnsLengthOfListAfterInser(): void
|
||||
public function testReturnsLengthOfListAfterInsert(): void
|
||||
{
|
||||
$redis = $this->getClient();
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ class MIGRATE_Test extends PredisCommandTestCase
|
||||
* @requiresRedisVersion >= 2.6.0
|
||||
* @group slow
|
||||
*/
|
||||
public function testReturnsErrorOnUnreacheableDestination(): void
|
||||
public function testReturnsErrorOnUnreachableDestination(): void
|
||||
{
|
||||
$this->expectException('Predis\Response\ServerException');
|
||||
$this->expectExceptionMessage('IOERR');
|
||||
|
||||
@@ -66,6 +66,8 @@ class VEMB_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @dataProvider quantisationProvider
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
@@ -98,6 +100,8 @@ class VEMB_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @dataProvider quantisationProvider
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
|
||||
@@ -62,6 +62,8 @@ class VGETATTR_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
@@ -86,6 +88,8 @@ class VGETATTR_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
|
||||
@@ -54,6 +54,7 @@ class VINFO_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
@@ -76,6 +77,7 @@ class VINFO_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
|
||||
@@ -63,6 +63,7 @@ class VLINKS_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
@@ -95,6 +96,8 @@ class VLINKS_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
|
||||
@@ -54,6 +54,8 @@ class VREM_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
@@ -78,6 +80,8 @@ class VREM_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
|
||||
@@ -59,6 +59,8 @@ class VSETATTR_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
@@ -78,6 +80,8 @@ class VSETATTR_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
|
||||
@@ -136,6 +136,7 @@ class VSIM_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 8.0.0
|
||||
*/
|
||||
|
||||
@@ -86,7 +86,6 @@ class XINFO_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 6.2.0
|
||||
*/
|
||||
@@ -110,7 +109,6 @@ class XINFO_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.0.0
|
||||
*/
|
||||
@@ -147,7 +145,6 @@ class XINFO_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.0.0
|
||||
*/
|
||||
@@ -180,7 +177,6 @@ class XINFO_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.2.0
|
||||
*/
|
||||
@@ -280,7 +276,6 @@ class XINFO_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.0.0
|
||||
*/
|
||||
|
||||
@@ -55,6 +55,7 @@ class XREADGROUP_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @group relay-fixme
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 5.0.0
|
||||
*/
|
||||
@@ -90,7 +91,6 @@ class XREADGROUP_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 5.0.0
|
||||
*/
|
||||
|
||||
@@ -56,7 +56,6 @@ class XREAD_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 5.0.0
|
||||
*/
|
||||
@@ -110,7 +109,6 @@ class XREAD_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group medium
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 5.0.0
|
||||
*/
|
||||
@@ -137,7 +135,6 @@ class XREAD_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.4.0
|
||||
*/
|
||||
@@ -167,7 +164,6 @@ class XREAD_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @requiresRedisVersion >= 5.0.0
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -88,7 +88,6 @@ class XSETID_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
* @requiresRedisVersion >= 5.0.0
|
||||
*/
|
||||
public function testSetIdExtended(): void
|
||||
|
||||
@@ -1123,7 +1123,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testParseIPv6AddresseAndPortPairInRedirectionPayload(): void
|
||||
public function testParseIPv6AddressAndPortPairInRedirectionPayload(): void
|
||||
{
|
||||
$movedResponse = new Response\Error('MOVED 1970 2001:db8:0:f101::2:6379');
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
namespace Predis\Pipeline;
|
||||
|
||||
use Predis\Client;
|
||||
use Predis\ClientInterface;
|
||||
use Predis\Command\Redis\PING;
|
||||
use Predis\Connection\Parameters;
|
||||
use Predis\Response;
|
||||
@@ -263,4 +264,47 @@ class AtomicTest extends PredisTestCase
|
||||
|
||||
$pipeline->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
*/
|
||||
public function testReplicationExecutesPipelineWithCRLFValues(): void
|
||||
{
|
||||
$parameters = $this->getDefaultParametersArray();
|
||||
|
||||
$client = $this->getClient(
|
||||
["tcp://{$parameters['host']}:{$parameters['port']}?role=master&database={$parameters['database']}&password={$parameters['password']}"],
|
||||
['replication' => 'predis']
|
||||
);
|
||||
|
||||
$results = $client->pipeline(function (Pipeline $pipe) {
|
||||
$pipe->set('foo', "bar\r\nbaz");
|
||||
$pipe->get('foo');
|
||||
});
|
||||
|
||||
$expectedResults = [
|
||||
new Response\Status('OK'),
|
||||
"bar\r\nbaz",
|
||||
];
|
||||
|
||||
$this->assertSameValues($expectedResults, $results);
|
||||
}
|
||||
|
||||
// ******************************************************************** //
|
||||
// ---- HELPER METHODS ------------------------------------------------ //
|
||||
// ******************************************************************** //
|
||||
|
||||
/**
|
||||
* Returns a client instance connected to the specified Redis server.
|
||||
*
|
||||
* @param array $parameters Additional connection parameters
|
||||
* @param array $options Additional client options
|
||||
*
|
||||
* @return ClientInterface
|
||||
*/
|
||||
protected function getClient(array $parameters = [], array $options = []): ClientInterface
|
||||
{
|
||||
return $this->createClient($parameters, $options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
namespace Predis\Pipeline;
|
||||
|
||||
use Predis\Client;
|
||||
use Predis\ClientInterface;
|
||||
use Predis\Command\Redis\PING;
|
||||
use Predis\Response;
|
||||
use PredisTestCase;
|
||||
|
||||
class FireAndForgetTest extends PredisTestCase
|
||||
@@ -47,16 +49,21 @@ class FireAndForgetTest extends PredisTestCase
|
||||
*/
|
||||
public function testSwitchesToMasterWithReplicationConnection(): void
|
||||
{
|
||||
$buffer = (new PING())->serializeCommand() . (new PING())->serializeCommand() . (new PING())->serializeCommand();
|
||||
$nodeConnection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock();
|
||||
$nodeConnection
|
||||
->expects($this->exactly(3))
|
||||
->method('write')
|
||||
->with((new PING())->serializeCommand());
|
||||
|
||||
$connection = $this->getMockBuilder('Predis\Connection\Replication\ReplicationInterface')
|
||||
->getMock();
|
||||
$connection
|
||||
->expects($this->once())
|
||||
->method('switchToMaster');
|
||||
$connection
|
||||
->expects($this->once())
|
||||
->method('write')
|
||||
->with($buffer);
|
||||
->expects($this->exactly(3))
|
||||
->method('getConnectionByCommand')
|
||||
->willReturn($nodeConnection);
|
||||
$connection
|
||||
->expects($this->never())
|
||||
->method('readResponse');
|
||||
@@ -89,4 +96,47 @@ class FireAndForgetTest extends PredisTestCase
|
||||
|
||||
$this->assertEmpty($pipeline->execute());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
*/
|
||||
public function testReplicationExecutesPipelineWithCRLFValues(): void
|
||||
{
|
||||
$parameters = $this->getDefaultParametersArray();
|
||||
|
||||
$client = $this->getClient(
|
||||
["tcp://{$parameters['host']}:{$parameters['port']}?role=master&database={$parameters['database']}&password={$parameters['password']}"],
|
||||
['replication' => 'predis']
|
||||
);
|
||||
|
||||
$results = $client->pipeline(function (Pipeline $pipe) {
|
||||
$pipe->set('foo', "bar\r\nbaz");
|
||||
$pipe->get('foo');
|
||||
});
|
||||
|
||||
$expectedResults = [
|
||||
new Response\Status('OK'),
|
||||
"bar\r\nbaz",
|
||||
];
|
||||
|
||||
$this->assertSameValues($expectedResults, $results);
|
||||
}
|
||||
|
||||
// ******************************************************************** //
|
||||
// ---- HELPER METHODS ------------------------------------------------ //
|
||||
// ******************************************************************** //
|
||||
|
||||
/**
|
||||
* Returns a client instance connected to the specified Redis server.
|
||||
*
|
||||
* @param array $parameters Additional connection parameters
|
||||
* @param array $options Additional client options
|
||||
*
|
||||
* @return ClientInterface
|
||||
*/
|
||||
protected function getClient(array $parameters = [], array $options = []): ClientInterface
|
||||
{
|
||||
return $this->createClient($parameters, $options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +321,11 @@ class PipelineTest extends PredisTestCase
|
||||
*/
|
||||
public function testSwitchesToMasterWithReplicationConnection(): void
|
||||
{
|
||||
$buffer = (new PING())->serializeCommand() . (new PING())->serializeCommand() . (new PING())->serializeCommand();
|
||||
$nodeConnection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock();
|
||||
$nodeConnection
|
||||
->expects($this->exactly(3))
|
||||
->method('write')
|
||||
->with((new PING())->serializeCommand());
|
||||
$pong = new Response\Status('PONG');
|
||||
|
||||
$connection = $this->getMockBuilder('Predis\Connection\Replication\ReplicationInterface')->getMock();
|
||||
@@ -329,9 +333,9 @@ class PipelineTest extends PredisTestCase
|
||||
->expects($this->once())
|
||||
->method('switchToMaster');
|
||||
$connection
|
||||
->expects($this->once())
|
||||
->method('write')
|
||||
->with($buffer);
|
||||
->expects($this->exactly(3))
|
||||
->method('getConnectionByCommand')
|
||||
->willReturn($nodeConnection);
|
||||
$connection
|
||||
->expects($this->exactly(3))
|
||||
->method('readResponse')
|
||||
@@ -644,6 +648,32 @@ class PipelineTest extends PredisTestCase
|
||||
$this->assertSameValues($expectedResults, $results);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @group relay-incompatible
|
||||
*/
|
||||
public function testReplicationExecutesPipelineWithCRLFValues(): void
|
||||
{
|
||||
$parameters = $this->getDefaultParametersArray();
|
||||
|
||||
$client = $this->getClient(
|
||||
["tcp://{$parameters['host']}:{$parameters['port']}?role=master&database={$parameters['database']}&password={$parameters['password']}"],
|
||||
['replication' => 'predis']
|
||||
);
|
||||
|
||||
$results = $client->pipeline(function (Pipeline $pipe) {
|
||||
$pipe->set('foo', "bar\r\nbaz");
|
||||
$pipe->get('foo');
|
||||
});
|
||||
|
||||
$expectedResults = [
|
||||
new Response\Status('OK'),
|
||||
"bar\r\nbaz",
|
||||
];
|
||||
|
||||
$this->assertSameValues($expectedResults, $results);
|
||||
}
|
||||
|
||||
// ******************************************************************** //
|
||||
// ---- HELPER METHODS ------------------------------------------------ //
|
||||
// ******************************************************************** //
|
||||
|
||||
@@ -42,7 +42,7 @@ class BulkResponseTest extends PredisTestCase
|
||||
public function testBulk(): void
|
||||
{
|
||||
$bulk = 'This is a bulk string.';
|
||||
$bulkLengh = strlen($bulk);
|
||||
$bulkLength = strlen($bulk);
|
||||
|
||||
$connection = $this->getMockConnectionOfType('Predis\Connection\CompositeConnectionInterface');
|
||||
$connection
|
||||
@@ -51,12 +51,12 @@ class BulkResponseTest extends PredisTestCase
|
||||
$connection
|
||||
->expects($this->once())
|
||||
->method('readBuffer')
|
||||
->with($this->equalTo($bulkLengh + 2))
|
||||
->with($this->equalTo($bulkLength + 2))
|
||||
->willReturn("$bulk\r\n");
|
||||
|
||||
$handler = new Handler\BulkResponse();
|
||||
|
||||
$this->assertSame($bulk, $handler->handle($connection, (string) $bulkLengh));
|
||||
$this->assertSame($bulk, $handler->handle($connection, (string) $bulkLength));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user