Predis\Connection\Aggregate\RedisCluster::remove PHP Метод

remove() публичный Метод

public remove ( Predis\Connection\NodeConnectionInterface $connection )
$connection Predis\Connection\NodeConnectionInterface
    public function remove(NodeConnectionInterface $connection)
    {
        if (false !== ($id = array_search($connection, $this->pool, true))) {
            unset($this->pool[$id], $this->slotsMap);
            $this->slots = array_diff($this->slots, array($connection));
            return true;
        }
        return false;
    }

Usage Example

 /**
  * @group disconnected
  */
 public function testRemovingConnectionResetsSlotsMap()
 {
     $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379');
     $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380');
     $cluster = new RedisCluster(new Connection\Factory());
     $cluster->add($connection1);
     $cluster->add($connection2);
     $cluster->setSlots(0, 2047, '127.0.0.1:6379');
     $cluster->setSlots(2048, 4095, '127.0.0.1:6380');
     $expectedMap = array_merge(array_fill(0, 2048, '127.0.0.1:6379'), array_fill(2048, 2048, '127.0.0.1:6380'));
     $this->assertSame($expectedMap, $cluster->getSlotsMap());
     $cluster->remove($connection1);
     $this->assertEmpty($cluster->getSlotsMap());
 }