Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 465b044

Browse files
authored
Improve performance of mget() for big list of keys
1 parent 4629747 commit 465b044

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Connection.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -844,10 +844,8 @@ protected function sendRawCommand($command, $params)
844844
*/
845845
private function parseResponse($params, $command = null)
846846
{
847-
$prettyCommand = implode(' ', $params);
848-
849847
if (($line = fgets($this->socket)) === false) {
850-
throw new SocketException("Failed to read from socket.\nRedis command was: " . $prettyCommand);
848+
throw new SocketException("Failed to read from socket.\nRedis command was: " . implode(' ', $params));
851849
}
852850
$type = $line[0];
853851
$line = mb_substr($line, 1, -2, '8bit');
@@ -864,7 +862,7 @@ private function parseResponse($params, $command = null)
864862
return $this->redirect($line, $command, $params);
865863
}
866864

867-
throw new Exception("Redis error: " . $line . "\nRedis command was: " . $prettyCommand);
865+
throw new Exception("Redis error: " . $line . "\nRedis command was: " . implode(' ', $params));
868866
case ':': // Integer reply
869867
// no cast to int as it is in the range of a signed 64 bit integer
870868
return $line;
@@ -876,7 +874,7 @@ private function parseResponse($params, $command = null)
876874
$data = '';
877875
while ($length > 0) {
878876
if (($block = fread($this->socket, $length)) === false) {
879-
throw new SocketException("Failed to read from socket.\nRedis command was: " . $prettyCommand);
877+
throw new SocketException("Failed to read from socket.\nRedis command was: " . implode(' ', $params));
880878
}
881879
$data .= $block;
882880
$length -= mb_strlen($block, '8bit');
@@ -892,7 +890,7 @@ private function parseResponse($params, $command = null)
892890

893891
return $data;
894892
default:
895-
throw new Exception('Received illegal data from redis: ' . $line . "\nRedis command was: " . $prettyCommand);
893+
throw new Exception('Received illegal data from redis: ' . $line . "\nRedis command was: " . implode(' ', $params));
896894
}
897895
}
898896

0 commit comments

Comments
 (0)