class Sentinel

Relay Sentinel client.

Constants

OPT_THROW_ON_ERR

Whether to throw an exception on -ERR replies.

OPT_AUTO_DISCOVER

Reserved for automatically discovering other sentinels in the cluster, so they may be used if we fail to communicate with the first one. This is not implemented yet: setOption() and getOption() always return false for it.

Methods

__construct(array|string|null $host = null, int $port = 26379, float $timeout = 0, mixed $persistent = null, int $retry_interval = 0, float $read_timeout = 0, mixed $auth = null, array|null $context = null)

Establishes a new connection to a Sentinel instance.

bool
ckquorum(string $master)

Check if the current Sentinel configuration is able to reach the quorum needed to failover a master, and the majority needed to authorize the failover.

bool
failover(string $master)

Force a failover as if the master was not reachable, and without asking for agreement to other Sentinels.

bool
flushconfig()

Force Sentinel to rewrite its configuration on disk, including the current Sentinel state.

array|false
getMasterAddrByName(string $master)

Returns the ip and port number of the master with that name.

array|false
getPrimaryAddrByName(string $master)

Returns the ip and port number of the primary with that name.

array|false
master(string $master)

Returns the state and info of the specified master.

array|false
primary(string $master)

Returns the state and info of the specified primary.

array|false
masters()

Returns a list of monitored masters and their state.

array|false
primaries()

Returns a list of monitored primaries and their state.

string
myid()

Returns the ID of the Sentinel instance.

string|bool
ping(string|null $message = null)

Returns PONG if no message is provided, otherwise returns the message.

int
reset(string $pattern)

Will reset all the masters with matching name.

array|false
sentinels(string $master)

Returns a list of sentinel instances for this master, and their state.

array|false
slaves(string $master)

Show a list of replicas for this master, and their state.

string|null
getLastError()

Returns the last error message, if any.

bool
setOption(int $option, mixed $value)

Sets a client option.

mixed
getOption(int $option)

Returns a client option.

Details

at line 5101
__construct(array|string|null $host = null, int $port = 26379, float $timeout = 0, mixed $persistent = null, int $retry_interval = 0, float $read_timeout = 0, mixed $auth = null, array|null $context = null)

Establishes a new connection to a Sentinel instance.

For backwards compatibility with PhpRedis 6.x, the constructor may be called with a single options array.

Parameters

array|string|null $host
int $port
float $timeout
mixed $persistent
int $retry_interval
float $read_timeout
mixed $auth
array|null $context

at line 5120
bool ckquorum(string $master)

Check if the current Sentinel configuration is able to reach the quorum needed to failover a master, and the majority needed to authorize the failover.

Parameters

string $master

Return Value

bool

at line 5130
bool failover(string $master)

Force a failover as if the master was not reachable, and without asking for agreement to other Sentinels.

Parameters

string $master

Return Value

bool

at line 5139
bool flushconfig()

Force Sentinel to rewrite its configuration on disk, including the current Sentinel state.

Return Value

bool

at line 5148
array|false getMasterAddrByName(string $master)

Returns the ip and port number of the master with that name.

Parameters

string $master

Return Value

array|false

at line 5159
array|false getPrimaryAddrByName(string $master)

Returns the ip and port number of the primary with that name.

Parameters

string $master

Return Value

array|false

at line 5168
array|false master(string $master)

Returns the state and info of the specified master.

Parameters

string $master

Return Value

array|false

at line 5179
array|false primary(string $master)

Returns the state and info of the specified primary.

Parameters

string $master

Return Value

array|false

at line 5187
array|false masters()

Returns a list of monitored masters and their state.

Return Value

array|false

at line 5197
array|false primaries()

Returns a list of monitored primaries and their state.

Return Value

array|false

at line 5205
string myid()

Returns the ID of the Sentinel instance.

Return Value

string

at line 5214
string|bool ping(string|null $message = null)

Returns PONG if no message is provided, otherwise returns the message.

Parameters

string|null $message

Return Value

string|bool

at line 5223
int reset(string $pattern)

Will reset all the masters with matching name.

Parameters

string $pattern

Return Value

int

at line 5232
array|false sentinels(string $master)

Returns a list of sentinel instances for this master, and their state.

Parameters

string $master

Return Value

array|false

at line 5241
array|false slaves(string $master)

Show a list of replicas for this master, and their state.

Parameters

string $master

Return Value

array|false

at line 5249
string|null getLastError()

Returns the last error message, if any.

Return Value

string|null

at line 5259
bool setOption(int $option, mixed $value)

Sets a client option.

Parameters

int $option
mixed $value

Return Value

bool

at line 5268
mixed getOption(int $option)

Returns a client option.

Parameters

int $option

Return Value

mixed