Credis_Sentinel::getMasterClient PHP Method

getMasterClient() public method

If a Credis_Client object exists for a master, return it. Otherwise create one and return it
public getMasterClient ( string $name ) : Credis_Client
$name string
return Credis_Client
    public function getMasterClient($name)
    {
        if (!isset($this->_master[$name])) {
            $this->_master[$name] = $this->createMasterClient($name);
        }
        return $this->_master[$name];
    }

Usage Example

Exemplo n.º 1
0
 public function testMasterClient()
 {
     $master = $this->sentinel->getMasterClient($this->sentinelConfig->clustername);
     $this->assertInstanceOf('Credis_Client', $master);
     $this->assertEquals($this->redisConfig[0]['port'], $master->getPort());
     $this->setExpectedException('CredisException', 'Master not found');
     $this->sentinel->getMasterClient('non-existing-cluster');
 }