mirror of
https://github.com/predis/predis.git
synced 2026-09-05 07:16:44 +00:00
Use a faster approach to serialize the POST data for HTTP requests to Webdis.
This commit is contained in:
@@ -83,11 +83,6 @@ class WebdisConnection implements IConnectionSingle {
|
||||
};
|
||||
}
|
||||
|
||||
private static function argumentsSerializer($str, $arg) {
|
||||
$str .= '/' . urlencode($arg);
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function connect() {
|
||||
// NOOP
|
||||
}
|
||||
@@ -109,16 +104,19 @@ class WebdisConnection implements IConnectionSingle {
|
||||
}
|
||||
|
||||
public function executeCommand(ICommand $command) {
|
||||
$params = $this->_parameters;
|
||||
$arguments = array_reduce($command->getArguments(), 'self::argumentsSerializer');
|
||||
$arguments = implode('/', array_map('urlencode', $command->getArguments()));
|
||||
|
||||
$request = new HttpRequest($this->_webdisUrl, HttpRequest::METH_POST);
|
||||
$request->setBody(sprintf('%s%s.raw', $command->getId(), $arguments));
|
||||
$request->setBody("{$command->getId()}/$arguments.raw");
|
||||
$request->send();
|
||||
|
||||
phpiredis_reader_feed($this->_reader, $request->getResponseBody());
|
||||
|
||||
$reply = phpiredis_reader_get_reply($this->_reader);
|
||||
return isset($reply->skipParse) ? $reply : $command->parseResponse($reply);
|
||||
if ($reply instanceof IReplyObject) {
|
||||
return $reply;
|
||||
}
|
||||
return $command->parseResponse($reply);
|
||||
}
|
||||
|
||||
public function getResource() {
|
||||
|
||||
Reference in New Issue
Block a user