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

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

Removes a connection instance by using its identifier.
public removeById ( string $connectionID ) : boolean
$connectionID string Connection identifier.
Результат boolean True if the connection was in the pool.
    public function removeById($connectionID)
    {
        if (isset($this->pool[$connectionID])) {
            unset($this->pool[$connectionID], $this->slotsMap);
            return true;
        }
        return false;
    }

Usage Example

 /**
  * @group disconnected
  */
 public function testRemovingConnectionsFromClusterByAlias()
 {
     $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);
     $this->assertTrue($cluster->removeById('127.0.0.1:6380'));
     $this->assertFalse($cluster->removeById('127.0.0.1:6390'));
     $this->assertSame(1, count($cluster));
 }