Switch from server profiles to commands factory.

This change reduces some unnecessary complexity in the library, Redis
commands do not change much after all. Developers can still implement
their own commands factory, inject new commands or override existing
ones. The "profile" client options has been renamed to "commands" and
it accepts instances of Predis\Command\FactoryInterface.

The test suite checks at runtime the version of the running instance
of Redis for integration tests to adapt itself automatically.
This commit is contained in:
Daniele Alessandri
2016-06-04 11:06:44 +02:00
parent 6e3f301588
commit 62b421f20e
136 changed files with 1684 additions and 4741 deletions
+7 -7
View File
@@ -14,9 +14,9 @@ require __DIR__.'/shared.php';
// Predis allows to set Lua scripts as read-only operations for replication.
// This works for both EVAL and EVALSHA and also for the client-side abstraction
// built upon them (Predis\Command\ScriptCommand). This example shows a slightly
// more complex configuration that injects a new script command in the server
// profile used by the new client instance and marks it marks it as a read-only
// operation for replication so that it will be executed on slaves.
// more complex configuration that injects a new script command in the command
// factory used by the client and marks it as a read-only operation so that it
// will be executed on slaves.
use Predis\Command\ScriptCommand;
use Predis\Connection\Aggregate\MasterSlaveReplication;
@@ -52,11 +52,11 @@ $parameters = array(
);
$options = array(
'profile' => function ($options, $option) {
$profile = $options->getDefault($option);
$profile->defineCommand('hmgetall', 'HashMultipleGetAll');
'commands' => function ($options) {
$commands = $options->getDefault('commands');
$commands->defineCommand('hmgetall', 'HashMultipleGetAll');
return $profile;
return $commands;
},
'replication' => function () {
$strategy = new ReplicationStrategy();