|
|
|
@@ -287,8 +287,8 @@ class Client {
|
|
|
|
|
return $transBlock !== null ? $multi->execute($transBlock) : $multi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function pubSubContext() {
|
|
|
|
|
return new PubSubContext($this);
|
|
|
|
|
public function pubSubContext(Array $options = null) {
|
|
|
|
|
return new PubSubContext($this, $options);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -417,7 +417,8 @@ class Protocol {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
abstract class Command {
|
|
|
|
|
private $_arguments, $_hash;
|
|
|
|
|
private $_hash;
|
|
|
|
|
private $_arguments = array();
|
|
|
|
|
|
|
|
|
|
public abstract function getCommandId();
|
|
|
|
|
|
|
|
|
@@ -431,22 +432,24 @@ abstract class Command {
|
|
|
|
|
if (isset($this->_hash)) {
|
|
|
|
|
return $this->_hash;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (isset($this->_arguments[0])) {
|
|
|
|
|
// TODO: should we throw an exception if the command does
|
|
|
|
|
// not support sharding?
|
|
|
|
|
$key = $this->_arguments[0];
|
|
|
|
|
|
|
|
|
|
$start = strpos($key, '{');
|
|
|
|
|
$end = strpos($key, '}');
|
|
|
|
|
if ($start !== false && $end !== false) {
|
|
|
|
|
if (isset($this->_arguments[0])) {
|
|
|
|
|
// TODO: should we throw an exception if the command does
|
|
|
|
|
// not support sharding?
|
|
|
|
|
$key = $this->_arguments[0];
|
|
|
|
|
|
|
|
|
|
$start = strpos($key, '{');
|
|
|
|
|
if ($start !== false) {
|
|
|
|
|
$end = strpos($key, '}', $start);
|
|
|
|
|
if ($end !== false) {
|
|
|
|
|
$key = substr($key, ++$start, $end - $start);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->_hash = $distributor->generateKey($key);
|
|
|
|
|
return $this->_hash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->_hash = $distributor->generateKey($key);
|
|
|
|
|
return $this->_hash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -469,11 +472,13 @@ abstract class Command {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getArguments() {
|
|
|
|
|
return isset($this->_arguments) ? $this->_arguments : array();
|
|
|
|
|
return $this->_arguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getArgument($index = 0) {
|
|
|
|
|
return isset($this->_arguments[$index]) ? $this->_arguments[$index] : null;
|
|
|
|
|
if (isset($this->_arguments[$index]) === true) {
|
|
|
|
|
return $this->_arguments[$index];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function parseResponse($data) {
|
|
|
|
@@ -491,8 +496,7 @@ abstract class InlineCommand extends Command {
|
|
|
|
|
$arguments[0] = implode($arguments[0], ' ');
|
|
|
|
|
}
|
|
|
|
|
return $command . (count($arguments) > 0
|
|
|
|
|
? ' ' . implode($arguments, ' ') . Protocol::NEWLINE
|
|
|
|
|
: Protocol::NEWLINE
|
|
|
|
|
? ' ' . implode($arguments, ' ') . "\r\n" : "\r\n"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -504,7 +508,7 @@ abstract class BulkCommand extends Command {
|
|
|
|
|
$data = implode($data, ' ');
|
|
|
|
|
}
|
|
|
|
|
return $command . ' ' . implode($arguments, ' ') . ' ' . strlen($data) .
|
|
|
|
|
Protocol::NEWLINE . $data . Protocol::NEWLINE;
|
|
|
|
|
"\r\n" . $data . "\r\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -521,14 +525,14 @@ abstract class MultiBulkCommand extends Command {
|
|
|
|
|
$cmd_args = $arguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$newline = Protocol::NEWLINE;
|
|
|
|
|
$cmdlen = strlen($command);
|
|
|
|
|
$reqlen = $argsc + 1;
|
|
|
|
|
|
|
|
|
|
$buffer = "*{$reqlen}{$newline}\${$cmdlen}{$newline}{$command}{$newline}";
|
|
|
|
|
foreach ($cmd_args as $argument) {
|
|
|
|
|
$buffer = "*{$reqlen}\r\n\${$cmdlen}\r\n{$command}\r\n";
|
|
|
|
|
for ($i = 0; $i < $reqlen - 1; $i++) {
|
|
|
|
|
$argument = $cmd_args[$i];
|
|
|
|
|
$arglen = strlen($argument);
|
|
|
|
|
$buffer .= "\${$arglen}{$newline}{$argument}{$newline}";
|
|
|
|
|
$buffer .= "\${$arglen}\r\n{$argument}\r\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $buffer;
|
|
|
|
@@ -543,10 +547,10 @@ interface IResponseHandler {
|
|
|
|
|
|
|
|
|
|
class ResponseStatusHandler implements IResponseHandler {
|
|
|
|
|
public function handle(Connection $connection, $status) {
|
|
|
|
|
if ($status === Protocol::OK) {
|
|
|
|
|
if ($status === 'OK') {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if ($status === Protocol::QUEUED) {
|
|
|
|
|
if ($status === 'QUEUED') {
|
|
|
|
|
return new ResponseQueued();
|
|
|
|
|
}
|
|
|
|
|
return $status;
|
|
|
|
@@ -566,44 +570,31 @@ class ResponseErrorSilentHandler implements IResponseHandler {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResponseBulkHandler implements IResponseHandler {
|
|
|
|
|
public function handle(Connection $connection, $dataLength) {
|
|
|
|
|
if (!is_numeric($dataLength)) {
|
|
|
|
|
public function handle(Connection $connection, $lengthString) {
|
|
|
|
|
$length = (int) $lengthString;
|
|
|
|
|
if ($length != $lengthString) {
|
|
|
|
|
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
$connection, "Cannot parse '$dataLength' as data length"
|
|
|
|
|
$connection, "Cannot parse '$length' as data length"
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($dataLength > 0) {
|
|
|
|
|
$value = $connection->readBytes($dataLength);
|
|
|
|
|
self::discardNewLine($connection);
|
|
|
|
|
return $value;
|
|
|
|
|
if ($length >= 0) {
|
|
|
|
|
return $length > 0 ? substr($connection->readBytes($length + 2), 0, -2) : '';
|
|
|
|
|
}
|
|
|
|
|
else if ($dataLength == 0) {
|
|
|
|
|
self::discardNewLine($connection);
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static function discardNewLine(Connection $connection) {
|
|
|
|
|
if ($connection->readBytes(2) !== Protocol::NEWLINE) {
|
|
|
|
|
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
$connection, 'Did not receive a new-line at the end of a bulk response'
|
|
|
|
|
));
|
|
|
|
|
if ($length == -1) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResponseMultiBulkHandler implements IResponseHandler {
|
|
|
|
|
public function handle(Connection $connection, $rawLength) {
|
|
|
|
|
if (!is_numeric($rawLength)) {
|
|
|
|
|
public function handle(Connection $connection, $lengthString) {
|
|
|
|
|
$listLength = (int) $lengthString;
|
|
|
|
|
if ($listLength != $lengthString) {
|
|
|
|
|
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
$connection, "Cannot parse '$rawLength' as data length"
|
|
|
|
|
$connection, "Cannot parse '$lengthString' as data length"
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$listLength = (int) $rawLength;
|
|
|
|
|
if ($listLength === -1) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
@@ -611,9 +602,19 @@ class ResponseMultiBulkHandler implements IResponseHandler {
|
|
|
|
|
$list = array();
|
|
|
|
|
|
|
|
|
|
if ($listLength > 0) {
|
|
|
|
|
$handlers = array();
|
|
|
|
|
$reader = $connection->getResponseReader();
|
|
|
|
|
for ($i = 0; $i < $listLength; $i++) {
|
|
|
|
|
$list[] = $reader->read($connection);
|
|
|
|
|
$header = $connection->readLine();
|
|
|
|
|
$prefix = $header[0];
|
|
|
|
|
if (isset($handlers[$prefix])) {
|
|
|
|
|
$handler = $handlers[$prefix];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$handler = $reader->getHandler($prefix);
|
|
|
|
|
$handlers[$prefix] = $handler;
|
|
|
|
|
}
|
|
|
|
|
$list[$i] = $handler->handle($connection, substr($header, 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -622,13 +623,14 @@ class ResponseMultiBulkHandler implements IResponseHandler {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResponseMultiBulkStreamHandler implements IResponseHandler {
|
|
|
|
|
public function handle(Connection $connection, $rawLength) {
|
|
|
|
|
if (!is_numeric($rawLength)) {
|
|
|
|
|
public function handle(Connection $connection, $lengthString) {
|
|
|
|
|
$listLength = (int) $lengthString;
|
|
|
|
|
if ($listLength != $lengthString) {
|
|
|
|
|
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
$connection, "Cannot parse '$rawLength' as data length"
|
|
|
|
|
$connection, "Cannot parse '$lengthString' as data length"
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
return new Shared\MultiBulkResponseIterator($connection, (int)$rawLength);
|
|
|
|
|
return new Shared\MultiBulkResponseIterator($connection, $lengthString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -637,14 +639,12 @@ class ResponseIntegerHandler implements IResponseHandler {
|
|
|
|
|
if (is_numeric($number)) {
|
|
|
|
|
return (int) $number;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if ($number !== Protocol::NULL) {
|
|
|
|
|
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
$connection, "Cannot parse '$number' as numeric response"
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
if ($number !== 'nil') {
|
|
|
|
|
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
$connection, "Cannot parse '$number' as numeric response"
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -678,26 +678,26 @@ class ResponseReader {
|
|
|
|
|
public function read(Connection $connection) {
|
|
|
|
|
$header = $connection->readLine();
|
|
|
|
|
if ($header === '') {
|
|
|
|
|
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
$connection, 'Unexpected empty header'
|
|
|
|
|
));
|
|
|
|
|
$this->throwMalformedResponse($connection, 'Unexpected empty header');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$prefix = $header[0];
|
|
|
|
|
$payload = strlen($header) > 1 ? substr($header, 1) : '';
|
|
|
|
|
|
|
|
|
|
if (!isset($this->_prefixHandlers[$prefix])) {
|
|
|
|
|
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
$connection, "Unknown prefix '$prefix'"
|
|
|
|
|
));
|
|
|
|
|
$this->throwMalformedResponse($connection, "Unknown prefix '$prefix'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$handler = $this->_prefixHandlers[$prefix];
|
|
|
|
|
return $handler->handle($connection, $payload);
|
|
|
|
|
return $handler->handle($connection, substr($header, 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function throwMalformedResponse(Connection $connection, $message) {
|
|
|
|
|
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
$connection, $message
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResponseError {
|
|
|
|
|
public $skipParse = true;
|
|
|
|
|
private $_message;
|
|
|
|
|
|
|
|
|
|
public function __construct($message) {
|
|
|
|
@@ -705,10 +705,10 @@ class ResponseError {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function __get($property) {
|
|
|
|
|
if ($property == 'error') {
|
|
|
|
|
if ($property === 'error') {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if ($property == 'message') {
|
|
|
|
|
if ($property === 'message') {
|
|
|
|
|
return $this->_message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -723,11 +723,21 @@ class ResponseError {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResponseQueued {
|
|
|
|
|
public $queued = true;
|
|
|
|
|
public $skipParse = true;
|
|
|
|
|
|
|
|
|
|
public function __toString() {
|
|
|
|
|
return Protocol::QUEUED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function __get($property) {
|
|
|
|
|
if ($property === 'queued') {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function __isset($property) {
|
|
|
|
|
return $property === 'queued';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
@@ -874,7 +884,7 @@ class MultiExecBlock {
|
|
|
|
|
}
|
|
|
|
|
$command = $client->createCommand($method, $arguments);
|
|
|
|
|
$response = $client->executeCommand($command);
|
|
|
|
|
if (!isset($response->queued)) {
|
|
|
|
|
if (!$response instanceof \Predis\ResponseQueued) {
|
|
|
|
|
$this->malformedServerResponse(
|
|
|
|
|
'The server did not respond with a QUEUED status reply'
|
|
|
|
|
);
|
|
|
|
@@ -987,6 +997,9 @@ class MultiExecBlock {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$this->reset();
|
|
|
|
|
if (isset($this->_options['on_retry']) && is_callable($this->_options['on_retry'])) {
|
|
|
|
|
call_user_func($this->_options['on_retry'], $this, $attemptsLeft);
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@@ -1016,7 +1029,7 @@ class MultiExecBlock {
|
|
|
|
|
// Since a MULTI/EXEC block cannot be initialized over a clustered
|
|
|
|
|
// connection, we can safely assume that Predis\Client::getConnection()
|
|
|
|
|
// will always return an instance of Predis\Connection.
|
|
|
|
|
Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
|
|
|
|
$this->_redisClient->getConnection(), $message
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
@@ -1034,12 +1047,16 @@ class PubSubContext implements \Iterator {
|
|
|
|
|
const STATUS_SUBSCRIBED = 0x0010;
|
|
|
|
|
const STATUS_PSUBSCRIBED = 0x0100;
|
|
|
|
|
|
|
|
|
|
private $_redisClient, $_subscriptions, $_isStillValid, $_position;
|
|
|
|
|
private $_redisClient, $_position, $_options;
|
|
|
|
|
|
|
|
|
|
public function __construct(Client $redisClient) {
|
|
|
|
|
public function __construct(Client $redisClient, Array $options = null) {
|
|
|
|
|
$this->checkCapabilities($redisClient);
|
|
|
|
|
$this->_options = $options ?: array();
|
|
|
|
|
$this->_redisClient = $redisClient;
|
|
|
|
|
$this->_statusFlags = self::STATUS_VALID;
|
|
|
|
|
|
|
|
|
|
$this->genericSubscribeInit('subscribe');
|
|
|
|
|
$this->genericSubscribeInit('psubscribe');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function __destruct() {
|
|
|
|
@@ -1061,6 +1078,19 @@ class PubSubContext implements \Iterator {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function genericSubscribeInit($subscribeAction) {
|
|
|
|
|
if (isset($this->_options[$subscribeAction])) {
|
|
|
|
|
if (is_array($this->_options[$subscribeAction])) {
|
|
|
|
|
foreach ($this->_options[$subscribeAction] as $subscription) {
|
|
|
|
|
$this->$subscribeAction($subscription);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$this->$subscribeAction($this->_options[$subscribeAction]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function isFlagSet($value) {
|
|
|
|
|
return ($this->_statusFlags & $value) === $value;
|
|
|
|
|
}
|
|
|
|
@@ -1342,8 +1372,7 @@ class Connection implements IConnection {
|
|
|
|
|
|
|
|
|
|
public function readResponse(Command $command) {
|
|
|
|
|
$response = $this->_reader->read($this);
|
|
|
|
|
$skipparse = isset($response->queued) || isset($response->error);
|
|
|
|
|
return $skipparse ? $response : $command->parseResponse($response);
|
|
|
|
|
return isset($response->skipParse) ? $response : $command->parseResponse($response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function executeCommand(Command $command) {
|
|
|
|
@@ -1379,7 +1408,7 @@ class Connection implements IConnection {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function readBytes($length) {
|
|
|
|
|
if ($length == 0) {
|
|
|
|
|
if ($length <= 0) {
|
|
|
|
|
throw new \InvalidArgumentException('Length parameter must be greater than 0');
|
|
|
|
|
}
|
|
|
|
|
$socket = $this->getSocket();
|
|
|
|
@@ -1400,12 +1429,12 @@ class Connection implements IConnection {
|
|
|
|
|
$value = '';
|
|
|
|
|
do {
|
|
|
|
|
$chunk = fgets($socket);
|
|
|
|
|
if ($chunk === false || strlen($chunk) == 0) {
|
|
|
|
|
if ($chunk === false || $chunk === '') {
|
|
|
|
|
$this->onCommunicationException('Error while reading line from the server');
|
|
|
|
|
}
|
|
|
|
|
$value .= $chunk;
|
|
|
|
|
}
|
|
|
|
|
while (substr($value, -2) !== Protocol::NEWLINE);
|
|
|
|
|
while (substr($value, -2) !== "\r\n");
|
|
|
|
|
return substr($value, 0, -2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1528,6 +1557,7 @@ abstract class RedisServerProfile {
|
|
|
|
|
return array(
|
|
|
|
|
'1.2' => '\Predis\RedisServer_v1_2',
|
|
|
|
|
'2.0' => '\Predis\RedisServer_v2_0',
|
|
|
|
|
'2.2' => '\Predis\RedisServer_v2_2',
|
|
|
|
|
'default' => '\Predis\RedisServer_v2_0',
|
|
|
|
|
'dev' => '\Predis\RedisServer_vNext',
|
|
|
|
|
);
|
|
|
|
@@ -1655,7 +1685,7 @@ class RedisServer_v1_2 extends RedisServerProfile {
|
|
|
|
|
'type' => '\Predis\Commands\Type',
|
|
|
|
|
|
|
|
|
|
/* commands operating on the key space */
|
|
|
|
|
'keys' => '\Predis\Commands\Keys',
|
|
|
|
|
'keys' => '\Predis\Commands\Keys_v1_2',
|
|
|
|
|
'randomkey' => '\Predis\Commands\RandomKey',
|
|
|
|
|
'randomKey' => '\Predis\Commands\RandomKey',
|
|
|
|
|
'rename' => '\Predis\Commands\Rename',
|
|
|
|
@@ -1789,6 +1819,9 @@ class RedisServer_v2_0 extends RedisServer_v1_2 {
|
|
|
|
|
'append' => '\Predis\Commands\Append',
|
|
|
|
|
'substr' => '\Predis\Commands\Substr',
|
|
|
|
|
|
|
|
|
|
/* commands operating on the key space */
|
|
|
|
|
'keys' => '\Predis\Commands\Keys',
|
|
|
|
|
|
|
|
|
|
/* commands operating on lists */
|
|
|
|
|
'blpop' => '\Predis\Commands\ListPopFirstBlocking',
|
|
|
|
|
'popFirstBlocking' => '\Predis\Commands\ListPopFirstBlocking',
|
|
|
|
@@ -1849,8 +1882,8 @@ class RedisServer_v2_0 extends RedisServer_v1_2 {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RedisServer_vNext extends RedisServer_v2_0 {
|
|
|
|
|
public function getVersion() { return '2.1'; }
|
|
|
|
|
class RedisServer_v2_2 extends RedisServer_v2_0 {
|
|
|
|
|
public function getVersion() { return '2.2'; }
|
|
|
|
|
public function getSupportedCommands() {
|
|
|
|
|
return array_merge(parent::getSupportedCommands(), array(
|
|
|
|
|
/* transactions */
|
|
|
|
@@ -1879,6 +1912,10 @@ class RedisServer_vNext extends RedisServer_v2_0 {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RedisServer_vNext extends RedisServer_v2_2 {
|
|
|
|
|
public function getVersion() { return 'DEV'; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
namespace Predis\Pipeline;
|
|
|
|
@@ -2422,12 +2459,11 @@ class Strlen extends \Predis\MultiBulkCommand {
|
|
|
|
|
class Keys extends \Predis\MultiBulkCommand {
|
|
|
|
|
public function canBeHashed() { return false; }
|
|
|
|
|
public function getCommandId() { return 'KEYS'; }
|
|
|
|
|
public function parseResponse($data) {
|
|
|
|
|
// TODO: is this behaviour correct?
|
|
|
|
|
if (is_array($data) || $data instanceof \Iterator) {
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
return strlen($data) > 0 ? explode(' ', $data) : array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Keys_v1_2 extends Keys {
|
|
|
|
|
public function parseResponse($data) {
|
|
|
|
|
return explode(' ', $data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|