Exemplo n.º 1
0
 /**
  * Constructor
  *
  * @param null|\Predis\Distribution\IDistributionStrategy $distributor
  */
 public function __construct(IDistributionStrategy $distributor = null)
 {
     parent::__construct(new RandomDistributionStrategy());
 }
Exemplo n.º 2
0
 /**
  * @group disconnected
  */
 public function testCanBeSerialized()
 {
     $connection1 = $this->getMockConnection('tcp://host1?alias=first');
     $connection2 = $this->getMockConnection('tcp://host2?alias=second');
     $cluster = new PredisCluster();
     $cluster->add($connection1);
     $cluster->add($connection2);
     // We use the following line to initialize the underlying hashring.
     $cluster->getConnectionByKey('foo');
     $unserialized = unserialize(serialize($cluster));
     $this->assertEquals($cluster, $unserialized);
 }
Exemplo n.º 3
0
 /**
  * @group disconnected
  */
 public function testExecutesCommandOnCorrectConnection()
 {
     $command = ServerProfile::getDefault()->createCommand('get', array('node01:5431'));
     $connection1 = $this->getMockConnection('tcp://host1:7001');
     $connection1->expects($this->once())->method('executeCommand')->with($command);
     $connection2 = $this->getMockConnection('tcp://host1:7002');
     $connection2->expects($this->never())->method('executeCommand');
     $cluster = new PredisCluster();
     $cluster->add($connection1);
     $cluster->add($connection2);
     $cluster->executeCommand($command);
 }