Documentation

SentinelReplication
in package
implements ReplicationInterface

Tags
author

Daniele Alessandri suppakilla@gmail.com

author

Ville Mattila ville@eventio.fi

Interfaces, Classes and Traits

ReplicationInterface
Defines a group of Redis nodes in a master / slave replication setup.

Table of Contents

$connectionFactory  : FactoryInterface
$current  : NodeConnectionInterface
$master  : NodeConnectionInterface
$retryLimit  : int
Max number of automatic retries of commands upon server failure.
$retryWait  : int
Time to wait in milliseconds before fetching a new configuration from one of the sentinel servers.
$sentinelConnection  : NodeConnectionInterface
$sentinels  : array<string|int, NodeConnectionInterface>
$sentinelTimeout  : float
$service  : string
$slaves  : array<string|int, NodeConnectionInterface>
$strategy  : ReplicationStrategy
$updateSentinels  : bool
Flag for automatic fetching of available sentinels.
__construct()  : mixed
__sleep()  : mixed
{@inheritdoc}
add()  : mixed
{@inheritdoc}
connect()  : mixed
{@inheritdoc}
disconnect()  : mixed
{@inheritdoc}
executeCommand()  : mixed
{@inheritdoc}
getConnection()  : mixed
{@inheritdoc}
getConnectionById()  : mixed
{@inheritdoc}
getCurrent()  : NodeConnectionInterface
Returns the connection instance currently in use by the aggregate connection.
getMaster()  : NodeConnectionInterface
Returns the connection instance for the master Redis node.
getReplicationStrategy()  : ReplicationStrategy
Returns the underlying replication strategy.
getSentinelConnection()  : NodeConnectionInterface
Returns the current sentinel connection.
getSlaves()  : NodeConnectionInterface
Returns a list of connection instances to slave nodes.
isConnected()  : mixed
{@inheritdoc}
querySentinel()  : mixed
Fetches the details for the master and slave servers from a sentinel.
readResponse()  : mixed
{@inheritdoc}
remove()  : mixed
{@inheritdoc}
setRetryLimit()  : mixed
Sets the maximum number of retries for commands upon server failure.
setRetryWait()  : mixed
Sets the time to wait (in milliseconds) before fetching a new configuration from one of the sentinels.
setSentinelTimeout()  : mixed
Sets a default timeout for connections to sentinels.
setUpdateSentinels()  : mixed
Set automatic fetching of available sentinels.
switchTo()  : mixed
Switches the internal connection instance in use.
switchToMaster()  : mixed
Switches to the master server.
switchToSlave()  : mixed
Switches to a random slave server.
updateSentinels()  : mixed
Fetches an updated list of sentinels from a sentinel.
writeRequest()  : mixed
{@inheritdoc}
assertConnectionRole()  : mixed
Asserts that the specified connection matches an expected role.
createSentinelConnection()  : NodeConnectionInterface
Creates a new connection to a sentinel server.
pickSlave()  : NodeConnectionInterface
Returns a random slave.
querySentinelForMaster()  : array<string|int, mixed>
Fetches the details for the master server from a sentinel.
querySentinelForSlaves()  : array<string|int, mixed>
Fetches the details for the slave servers from a sentinel.
reset()  : mixed
Resets the current connection.
wipeServerList()  : mixed
Wipes the current list of master and slaves nodes.
getConnectionInternal()  : NodeConnectionInterface
Returns the connection instance in charge for the given command.
handleSentinelErrorResponse()  : mixed
Handles error responses returned by redis-sentinel.
retryCommandOnFailure()  : mixed
Retries the execution of a command upon server failure after asking a new configuration to one of the sentinels.

Properties

$retryLimit

Max number of automatic retries of commands upon server failure.

protected int $retryLimit = 20

-1 = unlimited retry attempts 0 = no retry attempts (fails immediatly) n = fail only after n retry attempts

$retryWait

Time to wait in milliseconds before fetching a new configuration from one of the sentinel servers.

protected int $retryWait = 1000

$updateSentinels

Flag for automatic fetching of available sentinels.

protected bool $updateSentinels = false

Methods

__construct()

public __construct(string $service, array<string|int, mixed> $sentinels, FactoryInterface $connectionFactory[, ReplicationStrategy $strategy = null ]) : mixed
Parameters
$service : string

Name of the service for autodiscovery.

$sentinels : array<string|int, mixed>

Sentinel servers connection parameters.

$connectionFactory : FactoryInterface

Connection factory instance.

$strategy : ReplicationStrategy = null

Replication strategy instance.

Return values
mixed

getConnectionById()

{@inheritdoc}

public getConnectionById(mixed $connectionId) : mixed
Parameters
$connectionId : mixed
Return values
mixed

querySentinel()

Fetches the details for the master and slave servers from a sentinel.

public querySentinel() : mixed
Return values
mixed

setRetryLimit()

Sets the maximum number of retries for commands upon server failure.

public setRetryLimit(int $retry) : mixed

-1 = unlimited retry attempts 0 = no retry attempts (fails immediatly) n = fail only after n retry attempts

Parameters
$retry : int

Number of retry attempts.

Return values
mixed

setRetryWait()

Sets the time to wait (in milliseconds) before fetching a new configuration from one of the sentinels.

public setRetryWait(float $milliseconds) : mixed
Parameters
$milliseconds : float

Time to wait before the next attempt.

Return values
mixed

setSentinelTimeout()

Sets a default timeout for connections to sentinels.

public setSentinelTimeout(float $timeout) : mixed

When "timeout" is present in the connection parameters of sentinels, its value overrides the default sentinel timeout.

Parameters
$timeout : float

Timeout value.

Return values
mixed

setUpdateSentinels()

Set automatic fetching of available sentinels.

public setUpdateSentinels(bool $update) : mixed
Parameters
$update : bool

Enable or disable automatic updates.

Return values
mixed

switchTo()

Switches the internal connection instance in use.

public switchTo(mixed $connection) : mixed
Parameters
$connection : mixed

Alias of a connection

Return values
mixed

switchToMaster()

Switches to the master server.

public switchToMaster() : mixed
Return values
mixed

switchToSlave()

Switches to a random slave server.

public switchToSlave() : mixed
Return values
mixed

updateSentinels()

Fetches an updated list of sentinels from a sentinel.

public updateSentinels() : mixed
Return values
mixed

assertConnectionRole()

Asserts that the specified connection matches an expected role.

protected assertConnectionRole(NodeConnectionInterface $connection, string $role) : mixed
Parameters
$connection : NodeConnectionInterface

Connection to a redis server.

$role : string

Expected role of the server ("master", "slave" or "sentinel").

Tags
throws
RoleException
Return values
mixed

querySentinelForMaster()

Fetches the details for the master server from a sentinel.

protected querySentinelForMaster(NodeConnectionInterface $sentinel, string $service) : array<string|int, mixed>
Parameters
$sentinel : NodeConnectionInterface

Connection to a sentinel server.

$service : string

Name of the service.

Return values
array<string|int, mixed>

querySentinelForSlaves()

Fetches the details for the slave servers from a sentinel.

protected querySentinelForSlaves(NodeConnectionInterface $sentinel, string $service) : array<string|int, mixed>
Parameters
$sentinel : NodeConnectionInterface

Connection to a sentinel server.

$service : string

Name of the service.

Return values
array<string|int, mixed>

reset()

Resets the current connection.

protected reset() : mixed
Return values
mixed

wipeServerList()

Wipes the current list of master and slaves nodes.

protected wipeServerList() : mixed
Return values
mixed

retryCommandOnFailure()

Retries the execution of a command upon server failure after asking a new configuration to one of the sentinels.

private retryCommandOnFailure(CommandInterface $command, string $method) : mixed
Parameters
$command : CommandInterface

Command instance.

$method : string

Actual method.

Return values
mixed

Search results