avoid creating pipeline responses and do it lazy

This commit is contained in:
Jonathan Leibiusky
2011-05-30 13:43:21 -03:00
parent 44c3eef60e
commit d690833ed6
5 changed files with 51 additions and 16 deletions

View File

@@ -14,7 +14,28 @@ public class Pipeline extends Queable {
this.client = client;
}
public List<Object> sync() {
/**
* Syncronize pipeline by reading all responses. This operation close the
* pipeline. In order to get return values from pipelined commands, capture
* the different Response<?> of the commands you execute.
*/
public void sync() {
List<Object> unformatted = client.getAll();
for (Object o : unformatted) {
generateResponse(o);
}
}
/**
* Syncronize pipeline by reading all responses. This operation close the
* pipeline. Whenever possible try to avoid using this version and use
* Pipeline.sync() as it won't go through all the responses and generate the
* right response type (usually it is a waste of time).
*
* @return A list of all the responses in the order you executed them.
* @see sync
*/
public List<Object> syncAndReturnAll() {
List<Object> unformatted = client.getAll();
List<Object> formatted = new ArrayList<Object>();
for (Object o : unformatted) {