Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of mget() for big list of keys #265

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading