This commit is contained in:
nilskp
2014-10-03 15:36:09 -05:00
parent 321e5136be
commit 6ea1959cc5

View File

@@ -88,17 +88,18 @@ public class Pipeline extends MultiKeyPipelineBase {
} }
/** /**
* Syncronize pipeline by reading all responses. This operation close the * Synchronize pipeline by reading all responses. This operation close the
* pipeline. In order to get return values from pipelined commands, capture * pipeline. In order to get return values from pipelined commands, capture
* the different Response<?> of the commands you execute. * the different Response<?> of the commands you execute.
*/ */
public void sync() { public void sync() {
List<Object> unformatted = client.getMany(getPipelinedResponseLength()); if (client.isConnected()) {
for (Object o : unformatted) { List<Object> unformatted = client.getMany(getPipelinedResponseLength());
generateResponse(o); for (Object o : unformatted) {
} generateResponse(o);
}
}
} }
/** /**
* Syncronize pipeline by reading all responses. This operation close the * Syncronize pipeline by reading all responses. This operation close the
* pipeline. Whenever possible try to avoid using this version and use * pipeline. Whenever possible try to avoid using this version and use
@@ -108,17 +109,21 @@ public class Pipeline extends MultiKeyPipelineBase {
* @return A list of all the responses in the order you executed them. * @return A list of all the responses in the order you executed them.
*/ */
public List<Object> syncAndReturnAll() { public List<Object> syncAndReturnAll() {
List<Object> unformatted = client.getMany(getPipelinedResponseLength()); if (client.isConnected()) {
List<Object> formatted = new ArrayList<Object>(); List<Object> unformatted = client.getMany(getPipelinedResponseLength());
List<Object> formatted = new ArrayList<Object>();
for (Object o : unformatted) { for (Object o : unformatted) {
try { try {
formatted.add(generateResponse(o).get()); formatted.add(generateResponse(o).get());
} catch (JedisDataException e) { } catch (JedisDataException e) {
formatted.add(e); formatted.add(e);
} }
} }
return formatted; return formatted;
} else {
return java.util.Collections.<Object>emptyList();
}
} }
public Response<String> discard() { public Response<String> discard() {