I coded with libredis just for two days, and I like the idea of composition, it's interesting and nice.
However the documentation is not very clear.
After read the doc and code three times, I thought I could do it like this:
$batch = $libredis->create_batch();
// $batch->cmd...
$connection1 = $libredis->get_connection($config1);
$connection2 = $libredis->get_connection($config2);
$executor->add($connection1, $batch);
$executor->add($connection2, $batch);
$executor->execute();
Oh no, we cant do it, because we add the same batch with different connection in one executor.
I also thought it was right:
$batch1 = $libredis->create_batch();
$batch2 = $libredis->create_batch();
// $batch1 & $batch2 ->cmd...
$connection = $libredis->get_connection($config);
$executor->add($connection, $batch1);
$executor->add($connection, $batch2);
In fact, it is not allowed too. The first pair will execute timeout.
Maybe this is not a issue, because we could make unique connections in executor, and merge the cmds with one batch.
But this is not I thought at first. If the lib could solve the problem Internally, we could write more abstract and simple code in PHP.
Regards
KnightE
I coded with libredis just for two days, and I like the idea of composition, it's interesting and nice.
However the documentation is not very clear.
After read the doc and code three times, I thought I could do it like this:
Oh no, we cant do it, because we add the same batch with different connection in one executor.
I also thought it was right:
In fact, it is not allowed too. The first pair will execute timeout.
Maybe this is not a issue, because we could make unique connections in executor, and merge the cmds with one batch.
But this is not I thought at first. If the lib could solve the problem Internally, we could write more abstract and simple code in PHP.
Regards
KnightE