Improved the internals of MultiExecBlock::execute (slight reduction in memory usage; check for out-of-sync conditions between the client and the server)

This commit is contained in:
Daniele Alessandri
2010-01-06 12:13:51 +01:00
parent d51e8e0c25
commit 46dd3d6f19
+12 -2
View File
@@ -495,9 +495,19 @@ class MultiExecBlock {
if ($block !== null) {
$block($this);
}
$execReply = $this->_redisClient->exec();
for ($i = 0; $i < count($execReply); $i++) {
$returnValues[] = $this->_commands[$i]->parseResponse($execReply[$i]);
$commands = &$this->_commands;
$sizeofReplies = count($execReply);
if ($sizeofReplies !== count($commands)) {
// TODO: think of a better exception message
throw new ClientException("Out-of-sync");
}
for ($i = 0; $i < $sizeofReplies; $i++) {
$returnValues[] = $commands[$i]->parseResponse($execReply[$i]);
unset($commands[$i]);
}
}
catch (\Exception $exception) {