瀏覽代碼

Add an optional argument to MultiBulkResponseIterator::sync() to specify if the synchronization of an iterable multibulk response should be performed by consuming the rest of the reply or by closing the underlying connection.

Daniele Alessandri 15 年之前
父節點
當前提交
761e3a2527
共有 1 個文件被更改,包括 11 次插入3 次删除
  1. 11 3
      lib/Predis.php

+ 11 - 3
lib/Predis.php

@@ -2022,9 +2022,17 @@ class MultiBulkResponseIterator extends MultiBulkResponseIteratorBase {
         $this->sync();
     }
 
-    public function sync() {
-        while ($this->valid()) {
-            $this->next();
+    public function sync($drop = false) {
+        if ($drop == true) {
+            if ($this->valid()) {
+                $this->_position = $this->_replySize;
+                $this->_connection->disconnect();
+            }
+        }
+        else {
+            while ($this->valid()) {
+                $this->next();
+            }
         }
     }