Browse Source

Address #133 by reusing our own methods.

The main reason behind that code duplication was performance related
as we tried to reduce method calls when possible, even at the cost of
falling into the realm of early optimizations. Apparently we just lose
~400 req/sec on a 21000 req/sec basis ("SET foo bar") using PHP 5.5.3
(packaged by Ubuntu 13.10) on an Intel Q6600, so we will most likely
stick with this change for the sake of best practices.
Daniele Alessandri 11 năm trước cách đây
mục cha
commit
dd679661dd
2 tập tin đã thay đổi với 4 bổ sung12 xóa
  1. 3 11
      lib/Predis/Client.php
  2. 1 1
      tests/Predis/ClientTest.php

+ 3 - 11
lib/Predis/Client.php

@@ -218,18 +218,10 @@ class Client implements ClientInterface
      */
     public function __call($method, $arguments)
     {
-        $command = $this->profile->createCommand($method, $arguments);
-        $response = $this->connection->executeCommand($command);
-
-        if ($response instanceof ResponseObjectInterface) {
-            if ($response instanceof ResponseErrorInterface) {
-                $response = $this->onResponseError($command, $response);
-            }
+        $command  = $this->createCommand($method, $arguments);
+        $response = $this->executeCommand($command);
 
-            return $response;
-        }
-
-        return $command->parseResponse($response);
+        return $response;
     }
 
     /**

+ 1 - 1
tests/Predis/ClientTest.php

@@ -402,7 +402,7 @@ class ClientTest extends StandardTestCase
                 ->will($this->returnValue($ping));
 
         $options = array('profile' => $profile);
-        $client = $this->getMock('Predis\Client', array('createCommand'), array($connection, $options));
+        $client = $this->getMock('Predis\Client', null, array($connection, $options));
 
         $this->assertTrue($client->ping());
     }