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

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

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

Свойство Тип Описание
$connectionFactory Predis\Connection\FactoryInterface
$current Predis\Connection\NodeConnectionInterface
$master Predis\Connection\NodeConnectionInterface
$pool Predis\Connection\NodeConnectionInterface[]
$retryLimit integer -1 = unlimited retry attempts 0 = no retry attempts (fails immediatly) n = fail only after n retry attempts
$retryWait integer Time to wait in milliseconds before fetching a new configuration from one of the sentinel servers.
$sentinelConnection Predis\Connection\NodeConnectionInterface
$sentinelTimeout float
$sentinels Predis\Connection\NodeConnectionInterface[]
$service string
$slaves Predis\Connection\NodeConnectionInterface[]
$strategy Predis\Replication\ReplicationStrategy
$updateSentinels boolean Flag for automatic fetching of available sentinels.

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

Метод Описание
__construct ( string $service, array $sentinels, Predis\Connection\FactoryInterface $connectionFactory, ReplicationStrategy $strategy = null )
__sleep ( )
add ( Predis\Connection\NodeConnectionInterface $connection )
connect ( )
disconnect ( )
executeCommand ( Predis\Command\CommandInterface $command )
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.
getSentinelConnection ( ) : Predis\Connection\NodeConnectionInterface Returns the current sentinel connection.
getSlaves ( )
isConnected ( )
querySentinel ( ) Fetches the details for the master and slave servers from a sentinel.
readResponse ( Predis\Command\CommandInterface $command )
remove ( Predis\Connection\NodeConnectionInterface $connection )
setRetryLimit ( integer $retry ) Sets the maximum number of retries for commands upon server failure.
setRetryWait ( float $seconds ) Sets the time to wait (in seconds) before fetching a new configuration from one of the sentinels.
setSentinelTimeout ( float $timeout ) Sets a default timeout for connections to sentinels.
setUpdateSentinels ( boolean $update ) Set automatic fetching of available sentinels.
switchTo ( Predis\Connection\NodeConnectionInterface $connection ) Switches the internal connection in use by the backend.
switchToMaster ( )
switchToSlave ( )
updateSentinels ( ) Fetches an updated list of sentinels from a sentinel.
writeRequest ( Predis\Command\CommandInterface $command )

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

Метод Описание
assertConnectionRole ( Predis\Connection\NodeConnectionInterface $connection, string $role ) Asserts that the specified connection matches an expected role.
createSentinelConnection ( $parameters ) : Predis\Connection\NodeConnectionInterface Creates a new connection to a sentinel server.
pickSlave ( ) : Predis\Connection\NodeConnectionInterface Returns a random slave.
querySentinelForMaster ( Predis\Connection\NodeConnectionInterface $sentinel, string $service ) : array Fetches the details for the master server from a sentinel.
querySentinelForSlaves ( Predis\Connection\NodeConnectionInterface $sentinel, string $service ) : array Fetches the details for the slave servers from a sentinel.
reset ( ) Resets the current connection.
wipeServerList ( ) Wipes the current list of master and slaves nodes.

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

Метод Описание
getConnectionInternal ( Predis\Command\CommandInterface $command ) : Predis\Connection\NodeConnectionInterface Returns the connection instance in charge for the given command.
handleSentinelErrorResponse ( Predis\Connection\NodeConnectionInterface $sentinel, Predis\Response\ErrorInterface $error ) Handles error responses returned by redis-sentinel.
retryCommandOnFailure ( Predis\Command\CommandInterface $command, string $method ) : mixed Retries the execution of a command upon server failure after asking a new configuration to one of the sentinels.

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

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

public __construct ( string $service, array $sentinels, Predis\Connection\FactoryInterface $connectionFactory, ReplicationStrategy $strategy = null )
$service string Name of the service for autodiscovery.
$sentinels array Sentinel servers connection parameters.
$connectionFactory Predis\Connection\FactoryInterface Connection factory instance.
$strategy Predis\Replication\ReplicationStrategy Replication strategy instance.

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

public __sleep ( )

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

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

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

Asserts that the specified connection matches an expected role.
protected assertConnectionRole ( Predis\Connection\NodeConnectionInterface $connection, string $role )
$connection Predis\Connection\NodeConnectionInterface Connection to a redis server.
$role string Expected role of the server ("master", "slave" or "sentinel").

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

public connect ( )

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

Creates a new connection to a sentinel server.
protected createSentinelConnection ( $parameters ) : Predis\Connection\NodeConnectionInterface
Результат Predis\Connection\NodeConnectionInterface

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

public disconnect ( )

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

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

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`, `slave` or `sentinel`)
Результат Predis\Connection\NodeConnectionInterface | null

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

public getCurrent ( )

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

public getMaster ( )

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

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

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

If there is no active sentinel connection, a new connection is created.
public getSentinelConnection ( ) : Predis\Connection\NodeConnectionInterface
Результат Predis\Connection\NodeConnectionInterface

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

public getSlaves ( )

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

public isConnected ( )

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

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

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

Fetches the details for the master and slave servers from a sentinel.
public querySentinel ( )

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

Fetches the details for the master server from a sentinel.
protected querySentinelForMaster ( Predis\Connection\NodeConnectionInterface $sentinel, string $service ) : array
$sentinel Predis\Connection\NodeConnectionInterface Connection to a sentinel server.
$service string Name of the service.
Результат array

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

Fetches the details for the slave servers from a sentinel.
protected querySentinelForSlaves ( Predis\Connection\NodeConnectionInterface $sentinel, string $service ) : array
$sentinel Predis\Connection\NodeConnectionInterface Connection to a sentinel server.
$service string Name of the service.
Результат array

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 current connection.
protected reset ( )

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

-1 = unlimited retry attempts 0 = no retry attempts (fails immediatly) n = fail only after n retry attempts
public setRetryLimit ( integer $retry )
$retry integer Number of retry attempts.

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

Sets the time to wait (in seconds) before fetching a new configuration from one of the sentinels.
public setRetryWait ( float $seconds )
$seconds float Time to wait before the next attempt.

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

When "timeout" is present in the connection parameters of sentinels, its value overrides the default sentinel timeout.
public setSentinelTimeout ( float $timeout )
$timeout float Timeout value.

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

Set automatic fetching of available sentinels.
public setUpdateSentinels ( boolean $update )
$update boolean Enable or disable automatic updates.

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

Sentinel connections are not considered as part of the pool, meaning that trying to switch to a sentinel will throw an exception.
public switchTo ( Predis\Connection\NodeConnectionInterface $connection )
$connection Predis\Connection\NodeConnectionInterface Connection instance in the pool.

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

public switchToMaster ( )

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

public switchToSlave ( )

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

Fetches an updated list of sentinels from a sentinel.
public updateSentinels ( )

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

Wipes the current list of master and slaves nodes.
protected wipeServerList ( )

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

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

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

$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[]

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

-1 = unlimited retry attempts 0 = no retry attempts (fails immediatly) n = fail only after n retry attempts
protected int $retryLimit
Результат integer

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

Time to wait in milliseconds before fetching a new configuration from one of the sentinel servers.
protected int $retryWait
Результат integer

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

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

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

protected float $sentinelTimeout
Результат float

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

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

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

protected string $service
Результат string

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

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

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

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

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

Flag for automatic fetching of available sentinels.
protected bool $updateSentinels
Результат boolean