PHP 클래스 Credis_Sentinel

Implements the Sentinel API as mentioned on http://redis.io/topics/sentinel. Sentinel is aware of master and slave nodes in a cluster and returns instances of Credis_Client accordingly. The complexity of read/write splitting can also be abstract by calling the createCluster() method which returns a Credis_Cluster object that contains both the master server and a random slave. Credis_Cluster takes care of the read/write splitting
저자: Thijs Feryn ([email protected])
파일 보기 프로젝트 열기: colinmollenhour/credis 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_client Credis_Client Sentinel uses the same protocol as Redis which makes using Credis_Client convenient.
$_cluster array Contains an active instance of Credis_Cluster per master pool
$_master array Contains an active instance of Credis_Client representing a master
$_password string Store the AUTH password used by Credis_Client instances
$_slaves array Contains an array Credis_Client objects representing all slaves per master pool
$_standAlone boolean Use the phpredis extension or the standalone implementation

공개 메소드들

메소드 설명
__call ( string $name, array $args ) : mixed Catch-all method
__construct ( Credis_Client $client, string $password = NULL ) Connect with a Sentinel node. Sentinel will do the master and slave discovery
createCluster ( string $name, integer $db, integer $replicas = 128, boolean $selectRandomSlave = true, boolean $writeOnly = false ) : Credis_Cluster Returns a Redis cluster object containing a random slave and the master When $selectRandomSlave is true, only one random slave is passed.
createMasterClient ( string $name ) : Credis_Client Discover the master node automatically and return an instance of Credis_Client that connects to the master
createSlaveClients ( string $name ) : Credis_Client[] Discover the slave nodes automatically and return an array of Credis_Client objects
failover ( string $name ) : mixed Perform an auto-failover which will re-elect another master and make the current master a slave
forceStandalone ( ) : Credis_Sentinel
getCluster ( string $name, integer $db, integer $replicas = 128, boolean $selectRandomSlave = true, boolean $writeOnly = false ) : Credis_Cluster If a Credis_Cluster object exists, return it. Otherwise create one and return it.
getHost ( ) : string
getMasterAddressByName ( string $name ) : mixed Get the hostname and port for a specific master
getMasterClient ( string $name ) : Credis_Client If a Credis_Client object exists for a master, return it. Otherwise create one and return it
getPort ( ) : integer
getSlaveClients ( string $name ) : Credis_Client[] If an array of Credis_Client objects exist for a set of slaves, return them. Otherwise create and return them
master ( string $name ) : mixed Get the information for a specific master
masters ( ) : mixed Return information about all registered master servers
ping ( ) : mixed Check if the Sentinel is still responding
setClientDatabase ( integer $db )
setClientPassword ( null | string $password )
setClientPersistent ( string $persistent )
setClientTimeout ( float $timeout )
slaves ( string $name ) : mixed Return all information for slaves that are associated with a single master

메소드 상세

__call() 공개 메소드

Catch-all method
public __call ( string $name, array $args ) : mixed
$name string
$args array
리턴 mixed

__construct() 공개 메소드

Connect with a Sentinel node. Sentinel will do the master and slave discovery
public __construct ( Credis_Client $client, string $password = NULL )
$client Credis_Client
$password string (deprecated - use setClientPassword)

createCluster() 공개 메소드

When $selectRandomSlave is false, all clients are passed and hashing is applied in Credis_Cluster When $writeOnly is false, the master server will also be used for read commands.
사용 중단:
public createCluster ( string $name, integer $db, integer $replicas = 128, boolean $selectRandomSlave = true, boolean $writeOnly = false ) : Credis_Cluster
$name string
$db integer
$replicas integer
$selectRandomSlave boolean
$writeOnly boolean
리턴 Credis_Cluster

createMasterClient() 공개 메소드

Discover the master node automatically and return an instance of Credis_Client that connects to the master
public createMasterClient ( string $name ) : Credis_Client
$name string
리턴 Credis_Client

createSlaveClients() 공개 메소드

Discover the slave nodes automatically and return an array of Credis_Client objects
public createSlaveClients ( string $name ) : Credis_Client[]
$name string
리턴 Credis_Client[]

failover() 공개 메소드

Perform an auto-failover which will re-elect another master and make the current master a slave
public failover ( string $name ) : mixed
$name string
리턴 mixed

forceStandalone() 공개 메소드

사용 중단:
public forceStandalone ( ) : Credis_Sentinel
리턴 Credis_Sentinel

getCluster() 공개 메소드

If a Credis_Cluster object exists, return it. Otherwise create one and return it.
사용 중단:
public getCluster ( string $name, integer $db, integer $replicas = 128, boolean $selectRandomSlave = true, boolean $writeOnly = false ) : Credis_Cluster
$name string
$db integer
$replicas integer
$selectRandomSlave boolean
$writeOnly boolean
리턴 Credis_Cluster

getHost() 공개 메소드

public getHost ( ) : string
리턴 string

getMasterAddressByName() 공개 메소드

Get the hostname and port for a specific master
public getMasterAddressByName ( string $name ) : mixed
$name string
리턴 mixed

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

getPort() 공개 메소드

public getPort ( ) : integer
리턴 integer

getSlaveClients() 공개 메소드

If an array of Credis_Client objects exist for a set of slaves, return them. Otherwise create and return them
public getSlaveClients ( string $name ) : Credis_Client[]
$name string
리턴 Credis_Client[]

master() 공개 메소드

Get the information for a specific master
public master ( string $name ) : mixed
$name string
리턴 mixed

masters() 공개 메소드

Return information about all registered master servers
public masters ( ) : mixed
리턴 mixed

ping() 공개 메소드

Check if the Sentinel is still responding
public ping ( ) : mixed
리턴 mixed

setClientDatabase() 공개 메소드

public setClientDatabase ( integer $db )
$db integer

setClientPassword() 공개 메소드

public setClientPassword ( null | string $password )
$password null | string

setClientPersistent() 공개 메소드

public setClientPersistent ( string $persistent )
$persistent string

setClientTimeout() 공개 메소드

public setClientTimeout ( float $timeout )
$timeout float

slaves() 공개 메소드

Return all information for slaves that are associated with a single master
public slaves ( string $name ) : mixed
$name string
리턴 mixed

프로퍼티 상세

$_client 보호되어 있는 프로퍼티

Sentinel uses the same protocol as Redis which makes using Credis_Client convenient.
protected Credis_Client $_client
리턴 Credis_Client

$_cluster 보호되어 있는 프로퍼티

Contains an active instance of Credis_Cluster per master pool
protected array $_cluster
리턴 array

$_master 보호되어 있는 프로퍼티

Contains an active instance of Credis_Client representing a master
protected array $_master
리턴 array

$_password 보호되어 있는 프로퍼티

Store the AUTH password used by Credis_Client instances
protected string $_password
리턴 string

$_slaves 보호되어 있는 프로퍼티

Contains an array Credis_Client objects representing all slaves per master pool
protected array $_slaves
리턴 array

$_standAlone 보호되어 있는 프로퍼티

Use the phpredis extension or the standalone implementation
사용 중단:
protected bool $_standAlone
리턴 boolean