Credis_Sentinel::getMasterClient PHP 메소드

getMasterClient() 공개 메소드

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
리턴 Credis_Client
    public function getMasterClient($name)
    {
        if (!isset($this->_master[$name])) {
            $this->_master[$name] = $this->createMasterClient($name);
        }
        return $this->_master[$name];
    }

Usage Example

예제 #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');
 }