Removes a connection instance using its alias or index.
public removeById ( string $connectionID ) : boolean | ||
$connectionID | string | Alias or index of a connection. |
리턴 | boolean | Returns true if the connection was in the pool. |
/** * @group disconnected */ public function testRemovingConnectionsFromClusterByAlias() { $connection1 = $this->getMockConnection(); $connection2 = $this->getMockConnection('tcp://host1:7001?alias=node2'); $connection3 = $this->getMockConnection('tcp://host1:7002?alias=node3'); $cluster = new PredisCluster(); $cluster->add($connection1); $cluster->add($connection2); $cluster->add($connection3); $this->assertTrue($cluster->removeById(0)); $this->assertTrue($cluster->removeById('node2')); $this->assertFalse($cluster->removeById('node4')); $this->assertSame(1, count($cluster)); }