This connection backend offers smart support for redis-cluster by handling automatic slots map (re)generation upon -MOVED or -ASK responses returned by Redis when redirecting a client to a different node. The cluster can be pre-initialized using only a subset of the actual nodes in the cluster, Predis will do the rest by adjusting the slots map and creating the missing underlying connection instances on the fly. It is possible to pre-associate connections to a slots range with the "slots" parameter in the form "$first-$last". This can greatly reduce runtime node guessing and redirections. It is also possible to ask for the full and updated slots map directly to one of the nodes and optionally enable such a behaviour upon -MOVED redirections. Asking for the cluster configuration to Redis is actually done by issuing a CLUSTER SLOTS command to a random node in the pool.
Автор: Daniele Alessandri (suppakilla@gmail.com)
Наследование: implements ClusterInterface, implements IteratorAggregate, implements Countable
 /**
  * @medium
  * @group disconnected
  */
 public function testCanBeSerialized()
 {
     $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379?slots=0-1364');
     $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=1365-2729');
     $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=2730-4095');
     $cluster = new RedisCluster(new Connection\Factory());
     $cluster->add($connection1);
     $cluster->add($connection2);
     $cluster->add($connection3);
     $cluster->buildSlotsMap();
     $unserialized = unserialize(serialize($cluster));
     $this->assertEquals($cluster, $unserialized);
 }