Browse Source

Backported changes from the mainline library to the PHP 5.2 branch (up to commit 0e69438)

Daniele Alessandri 15 năm trước cách đây
mục cha
commit
6ca4087118
2 tập tin đã thay đổi với 29 bổ sung20 xóa
  1. 12 3
      CHANGELOG
  2. 17 17
      lib/Predis.php

+ 12 - 3
CHANGELOG

@@ -96,10 +96,19 @@ v0.6.0 (2010-05-??)
   * Connections now support float values for the connection_timeout parameter 
     to express timeouts with a microsecond resolution.
 
-  * The GET parameter for the SORT command now accepts also multiple key 
-    patterns by passing an array of strings.
+  * FIX: TCP connections now respect the read/write timeout parameter when 
+    reading the payload of server responses. Previously, stream_get_contents() 
+    was being used internally to read data from a connection but it looks like 
+    PHP does not honour the specified timeout for socket streams when inside 
+    this function.
 
-v0.5.1 (2010-01-27)
+  * FIX: The GET parameter for the SORT command now accepts also multiple key 
+    patterns by passing an array of strings. (ISSUE #1).
+
+  * FIX: Replies to the DEL command return the number of elements deleted by 
+    the server and not 0 or 1 interpreted as a boolean response. (ISSUE #4).
+
+v0.5.1 (2010-01-23)
   * RPOPLPUSH has been changed from bulk command to inline command in Redis
     1.2.1, so ListPopLastPushHead now extends InlineCommand. The old RPOPLPUSH
     behavior is still available via the ListPopLastPushHeadBulk class so that

+ 17 - 17
lib/Predis.php

@@ -157,7 +157,7 @@ class Predis_Client {
     public function getClientFor($connectionAlias) {
         if (!($this->_connection instanceof Predis_ConnectionCluster)) {
             throw new Predis_ClientException(
-                'This method is supported only when the client is connected to a cluster of connections.'
+                'This method is supported only when the client is connected to a cluster of connections'
             );
         }
 
@@ -1286,7 +1286,7 @@ class Predis_ConnectionCluster implements Predis_IConnection, IteratorAggregate
     public function getConnection(Predis_Command $command) {
         if ($command->canBeHashed() === false) {
             throw new Predis_ClientException(
-                sprintf("Cannot send '%s' commands to a cluster of connections.", $command->getCommandId())
+                sprintf("Cannot send '%s' commands to a cluster of connections", $command->getCommandId())
             );
         }
         return $this->_distributor->get($command->getHash($this->_distributor));
@@ -1334,6 +1334,10 @@ abstract class Predis_RedisServerProfile {
         return self::get('default');
     }
 
+    public static function getDevelopment() {
+        return self::get('dev');
+    }
+
     private static function predisServerProfiles() {
         return array(
             '1.2'     => 'Predis_RedisServer_v1_2',
@@ -1375,18 +1379,6 @@ abstract class Predis_RedisServerProfile {
         return new $profile();
     }
 
-    public function compareWith($version, $operator = null) {
-        // one could expect that PHP's version_compare would behave 
-        // the same way if invoked with 2 arguments or 3 arguments 
-        // with the third being NULL, but it is not like that.
-        // TODO: since version_compare considers 1 < 1.0 < 1.0.0, 
-        //       we might need to revise the behavior of this method.
-        return ($operator === null 
-            ? version_compare($this, $version)
-            : version_compare($this, $version, $operator)
-        );
-    }
-
     public function supportsCommand($command) {
         return isset($this->_registeredCommands[$command]);
     }
@@ -2026,9 +2018,17 @@ class Predis_Shared_MultiBulkResponseIterator extends Predis_Shared_MultiBulkRes
         $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();
+            }
         }
     }