Prechádzať zdrojové kódy

Create Predis\Cluster namespace and move related classes / interfaces.

Daniele Alessandri 12 rokov pred
rodič
commit
e54bc31212

+ 2 - 2
examples/CustomDistributionStrategy.php

@@ -16,8 +16,8 @@ require 'SharedConfigurations.php';
 // that implements Predis\Distribution\DistributionStrategyInterface.
 
 use Predis\Connection\PredisCluster;
-use Predis\Distribution\DistributionStrategyInterface;
-use Predis\Distribution\HashGeneratorInterface;
+use Predis\Cluster\Distribution\DistributionStrategyInterface;
+use Predis\Cluster\Hash\HashGeneratorInterface;
 
 class NaiveDistributionStrategy implements DistributionStrategyInterface, HashGeneratorInterface
 {

+ 1 - 2
lib/Predis/Command/Hash/CommandHashStrategyInterface.php → lib/Predis/Cluster/CommandHashStrategyInterface.php

@@ -9,10 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Command\Hash;
+namespace Predis\Cluster;
 
 use Predis\Command\CommandInterface;
-use Predis\Distribution\HashGeneratorInterface;
 
 /**
  * Interface for classes defining the strategy used to calculate an hash

+ 2 - 2
lib/Predis/Distribution/DistributionStrategyInterface.php → lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Distribution;
+namespace Predis\Cluster\Distribution;
 
 /**
  * A distributor implements the logic to automatically distribute
@@ -44,7 +44,7 @@ interface DistributionStrategyInterface
     /**
      * Returns the underlying hash generator instance.
      *
-     * @return HashGeneratorInterface
+     * @return Predis\Cluster\Hash\HashGeneratorInterface
      */
     public function getHashGenerator();
 }

+ 1 - 1
lib/Predis/Distribution/EmptyRingException.php → lib/Predis/Cluster/Distribution/EmptyRingException.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Distribution;
+namespace Predis\Cluster\Distribution;
 
 /**
  * Exception class that identifies empty rings.

+ 3 - 1
lib/Predis/Distribution/HashRing.php → lib/Predis/Cluster/Distribution/HashRing.php

@@ -9,7 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Distribution;
+namespace Predis\Cluster\Distribution;
+
+use Predis\Cluster\Hash\HashGeneratorInterface;
 
 /**
  * This class implements an hashring-based distributor that uses the same

+ 1 - 1
lib/Predis/Distribution/KetamaPureRing.php → lib/Predis/Cluster/Distribution/KetamaPureRing.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Distribution;
+namespace Predis\Cluster\Distribution;
 
 /**
  * This class implements an hashring-based distributor that uses the same

+ 1 - 1
lib/Predis/Distribution/CRC16HashGenerator.php → lib/Predis/Cluster/Hash/CRC16HashGenerator.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Distribution;
+namespace Predis\Cluster\Hash;
 
 /**
  * This class implements the CRC-CCITT-16 algorithm used by redis-cluster.

+ 1 - 1
lib/Predis/Distribution/HashGeneratorInterface.php → lib/Predis/Cluster/Hash/HashGeneratorInterface.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Distribution;
+namespace Predis\Cluster\Hash;
 
 /**
  * A generator of node keys implements the logic used to calculate the hash of

+ 2 - 2
lib/Predis/Command/Hash/PredisClusterHashStrategy.php → lib/Predis/Cluster/PredisClusterHashStrategy.php

@@ -9,10 +9,10 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Command\Hash;
+namespace Predis\Cluster;
 
+use Predis\Cluster\Hash\HashGeneratorInterface;
 use Predis\Command\CommandInterface;
-use Predis\Distribution\HashGeneratorInterface;
 
 /**
  * Default class used by Predis for client-side sharding to calculate

+ 2 - 2
lib/Predis/Command/Hash/RedisClusterHashStrategy.php → lib/Predis/Cluster/RedisClusterHashStrategy.php

@@ -9,10 +9,10 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Command\Hash;
+namespace Predis\Cluster;
 
+use Predis\Cluster\Hash\CRC16HashGenerator;
 use Predis\Command\CommandInterface;
-use Predis\Distribution\CRC16HashGenerator;
 
 /**
  * Default class used by Predis to calculate hashes out of keys of

+ 4 - 4
lib/Predis/Connection/PredisCluster.php

@@ -13,10 +13,10 @@ namespace Predis\Connection;
 
 use Predis\ClientException;
 use Predis\NotSupportedException;
+use Predis\Cluster\PredisClusterHashStrategy;
+use Predis\Cluster\Distribution\DistributionStrategyInterface;
+use Predis\Cluster\Distribution\HashRing;
 use Predis\Command\CommandInterface;
-use Predis\Command\Hash\PredisClusterHashStrategy;
-use Predis\Distribution\HashRing;
-use Predis\Distribution\DistributionStrategyInterface;
 
 /**
  * Abstraction for a cluster of aggregated connections to various Redis servers
@@ -168,7 +168,7 @@ class PredisCluster implements ClusterConnectionInterface, \IteratorAggregate, \
      * Returns the underlying command hash strategy used to hash
      * commands by their keys.
      *
-     * @return CommandHashStrategy
+     * @return Predis\Cluster\CommandHashStrategyInterface
      */
     public function getCommandHashStrategy()
     {

+ 2 - 4
lib/Predis/Connection/RedisCluster.php

@@ -14,10 +14,8 @@ namespace Predis\Connection;
 use Predis\ClientException;
 use Predis\NotSupportedException;
 use Predis\ResponseErrorInterface;
+use Predis\Cluster\RedisClusterHashStrategy;
 use Predis\Command\CommandInterface;
-use Predis\Command\Hash\CommandHashStrategyInterface;
-use Predis\Command\Hash\RedisClusterHashStrategy;
-use Predis\Distribution\CRC16HashGenerator;
 
 /**
  * Abstraction for Redis cluster (Redis v3.0).
@@ -266,7 +264,7 @@ class RedisCluster implements ClusterConnectionInterface, \IteratorAggregate, \C
      * Returns the underlying command hash strategy used to hash
      * commands by their keys.
      *
-     * @return CommandHashStrategy
+     * @return Predis\Cluster\CommandHashStrategyInterface
      */
     public function getCommandHashStrategy()
     {

+ 3 - 3
tests/PHPUnit/DistributionStrategyTestCase.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Distribution;
+namespace Predis\Cluster\Distribution;
 
 use \PHPUnit_Framework_TestCase as StandardTestCase;
 
@@ -21,7 +21,7 @@ abstract class DistributionStrategyTestCase extends StandardTestCase
     /**
      * Returns a new instance of the tested distributor.
      *
-     * @return Predis\Distribution\DistributionStrategyInterface
+     * @return Predis\Cluster\Distribution\DistributionStrategyInterface
      */
     protected abstract function getDistributorInstance();
 
@@ -49,7 +49,7 @@ abstract class DistributionStrategyTestCase extends StandardTestCase
      */
     public function testEmptyRingThrowsException()
     {
-        $this->setExpectedException('Predis\Distribution\EmptyRingException');
+        $this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException');
 
         $ring = $this->getDistributorInstance();
         $ring->get('nodekey');

+ 2 - 2
tests/Predis/Distribution/EmptyRingExceptionTest.php → tests/Predis/Cluster/Distribution/EmptyRingExceptionTest.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Distribution;
+namespace Predis\Cluster\Distribution;
 
 use \PHPUnit_Framework_TestCase as StandardTestCase;
 
@@ -24,7 +24,7 @@ class EmptyRingExceptionTest extends StandardTestCase
     public function testExceptionMessage()
     {
         $message = 'Empty Ring';
-        $this->setExpectedException('Predis\Distribution\EmptyRingException', $message);
+        $this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException', $message);
 
         throw new EmptyRingException($message);
     }

+ 1 - 1
tests/Predis/Distribution/HashRingTest.php → tests/Predis/Cluster/Distribution/HashRingTest.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Distribution;
+namespace Predis\Cluster\Distribution;
 
 /**
  * @todo To be improved.

+ 1 - 1
tests/Predis/Distribution/KetamaPureRingTest.php → tests/Predis/Cluster/Distribution/KetamaPureRingTest.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Distribution;
+namespace Predis\Cluster\Distribution;
 
 /**
  * @todo To be improved.

+ 2 - 2
tests/Predis/Command/Hash/PredisClusterHashStrategyTest.php → tests/Predis/Cluster/PredisClusterHashStrategyTest.php

@@ -9,11 +9,11 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Command\Hash;
+namespace Predis\Cluster;
 
 use \PHPUnit_Framework_TestCase as StandardTestCase;
 
-use Predis\Distribution\HashRing;
+use Predis\Cluster\Distribution\HashRing;
 use Predis\Profile\ServerProfile;
 
 /**

+ 1 - 1
tests/Predis/Command/Hash/RedisClusterHashStrategyTest.php → tests/Predis/Cluster/RedisClusterHashStrategyTest.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Predis\Command\Hash;
+namespace Predis\Cluster;
 
 use \PHPUnit_Framework_TestCase as StandardTestCase;
 

+ 1 - 1
tests/Predis/Connection/PredisClusterTest.php

@@ -26,7 +26,7 @@ class PredisClusterTest extends StandardTestCase
     public function testExposesCommandHashStrategy()
     {
         $cluster = new PredisCluster();
-        $this->assertInstanceOf('Predis\Command\Hash\PredisClusterHashStrategy', $cluster->getCommandHashStrategy());
+        $this->assertInstanceOf('Predis\Cluster\PredisClusterHashStrategy', $cluster->getCommandHashStrategy());
     }
 
     /**