Predis\Connection\Aggregate\PredisCluster::remove PHP Method

remove() public method

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

Usage Example

 /**
  * @group disconnected
  */
 public function testRemovingConnectionsFromCluster()
 {
     $connection1 = $this->getMockConnection();
     $connection2 = $this->getMockConnection();
     $connection3 = $this->getMockConnection();
     $cluster = new PredisCluster();
     $cluster->add($connection1);
     $cluster->add($connection2);
     $this->assertTrue($cluster->remove($connection1));
     $this->assertFalse($cluster->remove($connection3));
     $this->assertSame(1, count($cluster));
 }