Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The connection & batch in executor cant be reused #8

Open
KnightE opened this issue Sep 24, 2011 · 0 comments
Open

The connection & batch in executor cant be reused #8

KnightE opened this issue Sep 24, 2011 · 0 comments

Comments

@KnightE
Copy link

KnightE commented Sep 24, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant