PHP Класс Predis\Connection\Replication\MasterSlaveReplication

Автор: Daniele Alessandri ([email protected])
Наследование: implements Predis\Connection\Replication\ReplicationInterface
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$aliases Predis\Connection\NodeConnectionInterface[]
$autoDiscovery boolean
$connectionFactory Predis\Connection\FactoryInterface
$current Predis\Connection\NodeConnectionInterface
$master Predis\Connection\NodeConnectionInterface
$pool Predis\Connection\NodeConnectionInterface[]
$slaves Predis\Connection\NodeConnectionInterface[]
$strategy Predis\Replication\ReplicationStrategy

Открытые методы

Метод Описание
__construct ( ReplicationStrategy $strategy = null )
__sleep ( )
add ( Predis\Connection\NodeConnectionInterface $connection )
connect ( )
disconnect ( )
discover ( ) Fetches the replication configuration from one of the servers.
executeCommand ( Predis\Command\CommandInterface $command )
getConnectionByAlias ( string $alias ) : Predis\Connection\NodeConnectionInterface | null Returns a connection instance by its alias.
getConnectionByCommand ( Predis\Command\CommandInterface $command )
getConnectionById ( $id )
getConnectionByRole ( string $role ) : Predis\Connection\NodeConnectionInterface | null Returns a connection by its role.
getCurrent ( )
getMaster ( )
getReplicationStrategy ( ) : ReplicationStrategy Returns the underlying replication strategy.
getSlaves ( )
isConnected ( )
readResponse ( Predis\Command\CommandInterface $command )
remove ( Predis\Connection\NodeConnectionInterface $connection )
setAutoDiscovery ( boolean $value ) Configures the automatic discovery of the replication configuration on failure.
setConnectionFactory ( Predis\Connection\FactoryInterface $connectionFactory ) Sets the connection factory used to create the connections by the auto discovery procedure.
switchTo ( Predis\Connection\NodeConnectionInterface $connection ) Switches the internal connection in use by the backend.
switchToMaster ( )
switchToSlave ( )
writeRequest ( Predis\Command\CommandInterface $command )

Защищенные методы

Метод Описание
discoverFromMaster ( Predis\Connection\NodeConnectionInterface $connection, Predis\Connection\FactoryInterface $connectionFactory ) Discovers the replication configuration by contacting the master node.
discoverFromSlave ( Predis\Connection\NodeConnectionInterface $connection, Predis\Connection\FactoryInterface $connectionFactory ) Discovers the replication configuration by contacting one of the slaves.
pickSlave ( ) : Predis\Connection\NodeConnectionInterface Returns a random slave.
reset ( ) Resets the connection state.

Приватные методы

Метод Описание
getMasterOrDie ( ) : Predis\Connection\NodeConnectionInterface Returns the connection associated to the master server.
handleInfoResponse ( string $response ) : array Handles response from INFO.
retryCommandOnFailure ( Predis\Command\CommandInterface $command, string $method ) : mixed Retries the execution of a command upon slave failure.

Описание методов

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

public __construct ( ReplicationStrategy $strategy = null )
$strategy Predis\Replication\ReplicationStrategy

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

public __sleep ( )

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

public add ( Predis\Connection\NodeConnectionInterface $connection )
$connection Predis\Connection\NodeConnectionInterface

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

public connect ( )

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

public disconnect ( )

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

Fetches the replication configuration from one of the servers.
public discover ( )

discoverFromMaster() защищенный Метод

Discovers the replication configuration by contacting the master node.
protected discoverFromMaster ( Predis\Connection\NodeConnectionInterface $connection, Predis\Connection\FactoryInterface $connectionFactory )
$connection Predis\Connection\NodeConnectionInterface Connection to the master node.
$connectionFactory Predis\Connection\FactoryInterface Connection factory instance.

discoverFromSlave() защищенный Метод

Discovers the replication configuration by contacting one of the slaves.
protected discoverFromSlave ( Predis\Connection\NodeConnectionInterface $connection, Predis\Connection\FactoryInterface $connectionFactory )
$connection Predis\Connection\NodeConnectionInterface Connection to one of the slaves.
$connectionFactory Predis\Connection\FactoryInterface Connection factory instance.

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

public executeCommand ( Predis\Command\CommandInterface $command )
$command Predis\Command\CommandInterface

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

Returns a connection instance by its alias.
public getConnectionByAlias ( string $alias ) : Predis\Connection\NodeConnectionInterface | null
$alias string Connection alias.
Результат Predis\Connection\NodeConnectionInterface | null

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

public getConnectionByCommand ( Predis\Command\CommandInterface $command )
$command Predis\Command\CommandInterface

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

public getConnectionById ( $id )

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

Returns a connection by its role.
public getConnectionByRole ( string $role ) : Predis\Connection\NodeConnectionInterface | null
$role string Connection role (`master` or `slave`)
Результат Predis\Connection\NodeConnectionInterface | null

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

public getCurrent ( )

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

public getMaster ( )

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

Returns the underlying replication strategy.
public getReplicationStrategy ( ) : ReplicationStrategy
Результат Predis\Replication\ReplicationStrategy

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

public getSlaves ( )

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

public isConnected ( )

pickSlave() защищенный Метод

Returns a random slave.
protected pickSlave ( ) : Predis\Connection\NodeConnectionInterface
Результат Predis\Connection\NodeConnectionInterface

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

public readResponse ( Predis\Command\CommandInterface $command )
$command Predis\Command\CommandInterface

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

public remove ( Predis\Connection\NodeConnectionInterface $connection )
$connection Predis\Connection\NodeConnectionInterface

reset() защищенный Метод

Resets the connection state.
protected reset ( )

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

Configures the automatic discovery of the replication configuration on failure.
public setAutoDiscovery ( boolean $value )
$value boolean Enable or disable auto discovery.

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

Sets the connection factory used to create the connections by the auto discovery procedure.
public setConnectionFactory ( Predis\Connection\FactoryInterface $connectionFactory )
$connectionFactory Predis\Connection\FactoryInterface Connection factory instance.

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

Switches the internal connection in use by the backend.
public switchTo ( Predis\Connection\NodeConnectionInterface $connection )
$connection Predis\Connection\NodeConnectionInterface Connection instance in the pool.

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

public switchToMaster ( )

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

public switchToSlave ( )

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

public writeRequest ( Predis\Command\CommandInterface $command )
$command Predis\Command\CommandInterface

Описание свойств

$aliases защищенное свойство

protected NodeConnectionInterface[],Predis\Connection $aliases
Результат Predis\Connection\NodeConnectionInterface[]

$autoDiscovery защищенное свойство

protected bool $autoDiscovery
Результат boolean

$connectionFactory защищенное свойство

protected FactoryInterface,Predis\Connection $connectionFactory
Результат Predis\Connection\FactoryInterface

$current защищенное свойство

protected NodeConnectionInterface,Predis\Connection $current
Результат Predis\Connection\NodeConnectionInterface

$master защищенное свойство

protected NodeConnectionInterface,Predis\Connection $master
Результат Predis\Connection\NodeConnectionInterface

$pool защищенное свойство

protected NodeConnectionInterface[],Predis\Connection $pool
Результат Predis\Connection\NodeConnectionInterface[]

$slaves защищенное свойство

protected NodeConnectionInterface[],Predis\Connection $slaves
Результат Predis\Connection\NodeConnectionInterface[]

$strategy защищенное свойство

protected ReplicationStrategy,Predis\Replication $strategy
Результат Predis\Replication\ReplicationStrategy