ClusterStrategy
in package
implements
StrategyInterface
Common class implementing the logic needed to support clustering strategies.
Tags
Interfaces, Classes and Traits
- StrategyInterface
- Interface for classes defining the strategy used to calculate an hash out of keys extracted from supported commands.
Table of Contents
- $commands : mixed
- __construct() : mixed
- getSlot() : int
- Returns a slot for the given command used for clustering distribution or NULL when this is not possible.
- getSupportedCommands() : array<string|int, mixed>
- Returns the list of IDs for the supported commands.
- setCommandHandler() : mixed
- Sets an handler for the specified command ID.
- checkSameSlotForKeys() : bool
- Checks if the specified array of keys will generate the same hash.
- extractKeyTag() : string
- Returns only the hashable part of a key (delimited by "{...}"), or the whole key if a key tag is not found in the string.
- getDefaultCommands() : array<string|int, mixed>
- Returns the default map of supported commands with their handlers.
- getKeyFromAllArguments() : string|null
- Extracts the key from a command with multiple keys only when all keys in the arguments array produce the same hash.
- getKeyFromBitOp() : string|null
- Extracts the key from BITOP command.
- getKeyFromBlockingListCommands() : string|null
- Extracts the key from BLPOP and BRPOP commands.
- getKeyFromFirstArgument() : string
- Extracts the key from the first argument of a command instance.
- getKeyFromGeoradiusCommands() : string|null
- Extracts the key from GEORADIUS and GEORADIUSBYMEMBER commands.
- getKeyFromInterleavedArguments() : string|null
- Extracts the key from a command with multiple keys only when all keys in the arguments array produce the same hash.
- getKeyFromScriptingCommands() : string|null
- Extracts the key from EVAL and EVALSHA commands.
- getKeyFromSortCommand() : string|null
- Extracts the key from SORT command.
- getKeyFromZsetAggregationCommands() : string|null
- Extracts the key from ZINTERSTORE and ZUNIONSTORE commands.
Properties
$commands
protected
mixed
$commands
Methods
__construct()
public
__construct() : mixed
Return values
mixed —getSlot()
Returns a slot for the given command used for clustering distribution or NULL when this is not possible.
public
getSlot(CommandInterface $command) : int
Parameters
- $command : CommandInterface
-
Command instance.
Return values
int —getSupportedCommands()
Returns the list of IDs for the supported commands.
public
getSupportedCommands() : array<string|int, mixed>
Return values
array<string|int, mixed> —setCommandHandler()
Sets an handler for the specified command ID.
public
setCommandHandler(string $commandID[, mixed $callback = null ]) : mixed
The signature of the callback must have a single parameter of type Predis\Command\CommandInterface.
When the callback argument is omitted or NULL, the previously associated handler for the specified command ID is removed.
Parameters
- $commandID : string
-
Command ID.
- $callback : mixed = null
-
A valid callable object, or NULL to unset the handler.
Tags
Return values
mixed —checkSameSlotForKeys()
Checks if the specified array of keys will generate the same hash.
protected
checkSameSlotForKeys(array<string|int, mixed> $keys) : bool
Parameters
- $keys : array<string|int, mixed>
-
Array of keys.
Return values
bool —extractKeyTag()
Returns only the hashable part of a key (delimited by "{...}"), or the whole key if a key tag is not found in the string.
protected
extractKeyTag(string $key) : string
Parameters
- $key : string
-
A key.
Return values
string —getDefaultCommands()
Returns the default map of supported commands with their handlers.
protected
getDefaultCommands() : array<string|int, mixed>
Return values
array<string|int, mixed> —getKeyFromAllArguments()
Extracts the key from a command with multiple keys only when all keys in the arguments array produce the same hash.
protected
getKeyFromAllArguments(CommandInterface $command) : string|null
Parameters
- $command : CommandInterface
-
Command instance.
Return values
string|null —getKeyFromBitOp()
Extracts the key from BITOP command.
protected
getKeyFromBitOp(CommandInterface $command) : string|null
Parameters
- $command : CommandInterface
-
Command instance.
Return values
string|null —getKeyFromBlockingListCommands()
Extracts the key from BLPOP and BRPOP commands.
protected
getKeyFromBlockingListCommands(CommandInterface $command) : string|null
Parameters
- $command : CommandInterface
-
Command instance.
Return values
string|null —getKeyFromFirstArgument()
Extracts the key from the first argument of a command instance.
protected
getKeyFromFirstArgument(CommandInterface $command) : string
Parameters
- $command : CommandInterface
-
Command instance.
Return values
string —getKeyFromGeoradiusCommands()
Extracts the key from GEORADIUS and GEORADIUSBYMEMBER commands.
protected
getKeyFromGeoradiusCommands(CommandInterface $command) : string|null
Parameters
- $command : CommandInterface
-
Command instance.
Return values
string|null —getKeyFromInterleavedArguments()
Extracts the key from a command with multiple keys only when all keys in the arguments array produce the same hash.
protected
getKeyFromInterleavedArguments(CommandInterface $command) : string|null
Parameters
- $command : CommandInterface
-
Command instance.
Return values
string|null —getKeyFromScriptingCommands()
Extracts the key from EVAL and EVALSHA commands.
protected
getKeyFromScriptingCommands(CommandInterface $command) : string|null
Parameters
- $command : CommandInterface
-
Command instance.
Return values
string|null —getKeyFromSortCommand()
Extracts the key from SORT command.
protected
getKeyFromSortCommand(CommandInterface $command) : string|null
Parameters
- $command : CommandInterface
-
Command instance.
Return values
string|null —getKeyFromZsetAggregationCommands()
Extracts the key from ZINTERSTORE and ZUNIONSTORE commands.
protected
getKeyFromZsetAggregationCommands(CommandInterface $command) : string|null
Parameters
- $command : CommandInterface
-
Command instance.