Skip to content

Commit

Permalink
Merge pull request #265 from rob006/patch-1
Browse files Browse the repository at this point in the history
Improve performance of `mget()` for big list of keys
  • Loading branch information
bizley authored Oct 20, 2023
2 parents 4629747 + 309af2c commit d09895f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Yii Framework 2 redis extension Change Log
2.0.19 under development
------------------------

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


2.0.18 September 04, 2022
Expand Down
10 changes: 4 additions & 6 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,10 +844,8 @@ protected function sendRawCommand($command, $params)
*/
private function parseResponse($params, $command = null)
{
$prettyCommand = implode(' ', $params);

if (($line = fgets($this->socket)) === false) {
throw new SocketException("Failed to read from socket.\nRedis command was: " . $prettyCommand);
throw new SocketException("Failed to read from socket.\nRedis command was: " . implode(' ', $params));
}
$type = $line[0];
$line = mb_substr($line, 1, -2, '8bit');
Expand All @@ -864,7 +862,7 @@ private function parseResponse($params, $command = null)
return $this->redirect($line, $command, $params);
}

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

return $data;
default:
throw new Exception('Received illegal data from redis: ' . $line . "\nRedis command was: " . $prettyCommand);
throw new Exception('Received illegal data from redis: ' . $line . "\nRedis command was: " . implode(' ', $params));
}
}

Expand Down

0 comments on commit d09895f

Please sign in to comment.