use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method testCloseableWithMulti.
@Test
public void testCloseableWithMulti() throws IOException {
// we need to test with fresh instance of Jedis
Jedis jedis2 = new Jedis(hnp.getHost(), hnp.getPort(), 500);
jedis2.auth("foobared");
Pipeline pipeline = jedis2.pipelined();
Response<String> retFuture1 = pipeline.set("a", "1");
Response<String> retFuture2 = pipeline.set("b", "2");
pipeline.multi();
pipeline.set("a", "a");
pipeline.set("b", "b");
pipeline.close();
try {
pipeline.exec();
fail("close should discard transaction");
} catch (JedisDataException e) {
assertTrue(e.getMessage().contains("EXEC without MULTI"));
// pass
}
// it shouldn't meet any exception
retFuture1.get();
retFuture2.get();
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method pipelineResponseWithinPipeline.
@Test(expected = JedisDataException.class)
public void pipelineResponseWithinPipeline() {
jedis.set("string", "foo");
Pipeline p = jedis.pipelined();
Response<String> string = p.get("string");
string.get();
p.sync();
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method pipelineExecShoudThrowJedisDataExceptionWhenNotInMulti.
@Test(expected = JedisDataException.class)
public void pipelineExecShoudThrowJedisDataExceptionWhenNotInMulti() {
Pipeline pipeline = jedis.pipelined();
pipeline.exec();
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method pipelineSelect.
@Test
public void pipelineSelect() {
Pipeline p = jedis.pipelined();
p.select(1);
p.sync();
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method testEvalNestedLists.
@Test
public void testEvalNestedLists() {
String script = "return { {KEYS[1]} , {2} }";
Pipeline p = jedis.pipelined();
Response<Object> result = p.eval(script, 1, "key1");
p.sync();
List<?> results = (List<?>) result.get();
assertThat((List<String>) results.get(0), listWithItem("key1"));
assertThat((List<Long>) results.get(1), listWithItem(2L));
}
Aggregations