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

@@ -46,7 +46,7 @@ public class PipeliningTest extends Assert {
Pipeline p = jedis.pipelined();
p.set("foo", "bar");
p.get("foo");
results = p.sync();
results = p.syncAndReturnAll();
assertEquals(2, results.size());
assertEquals("OK", results.get(0));

View File

@@ -5,7 +5,7 @@ import java.net.UnknownHostException;
import java.util.Calendar;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.PipelineBlock;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.tests.HostAndPortUtil;
import redis.clients.jedis.tests.HostAndPortUtil.HostAndPort;
@@ -22,15 +22,13 @@ public class PipelinedGetSetBenchmark {
long begin = Calendar.getInstance().getTimeInMillis();
jedis.pipelined(new PipelineBlock() {
public void execute() {
for (int n = 0; n <= TOTAL_OPERATIONS; n++) {
String key = "foo" + n;
set(key, "bar" + n);
get(key);
}
}
});
Pipeline p = jedis.pipelined();
for (int n = 0; n <= TOTAL_OPERATIONS; n++) {
String key = "foo" + n;
p.set(key, "bar" + n);
p.get(key);
}
p.sync();
long elapsed = Calendar.getInstance().getTimeInMillis() - begin;