Skip to content

Commit d09895f

Browse files
authored
Merge pull request #265 from rob006/patch-1
Improve performance of `mget()` for big list of keys
2 parents 4629747 + 309af2c commit d09895f

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Yii Framework 2 redis extension Change Log
44
2.0.19 under development
55
------------------------
66

7-
- no changes in this release.
7+
- Enh #264: Improve performance of `mget()` for big list of keys (alx-xc, rob006)
88

99

1010
2.0.18 September 04, 2022

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)