use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method testCloseable.
@Test
public void testCloseable() 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.close();
// 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 testEvalKeyAndArg.
@Test
public void testEvalKeyAndArg() {
String key = "test";
String arg = "3";
String script = "redis.call('INCRBY', KEYS[1], ARGV[1]) redis.call('INCRBY', KEYS[1], ARGV[1])";
Pipeline p = jedis.pipelined();
p.set(key, "0");
Response<Object> result0 = p.eval(script, Arrays.asList(key), Arrays.asList(arg));
p.incr(key);
Response<Object> result1 = p.eval(script, Arrays.asList(key), Arrays.asList(arg));
Response<String> result2 = p.get(key);
p.sync();
assertNull(result0.get());
assertNull(result1.get());
assertEquals("13", result2.get());
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method piplineWithError.
@Test
public void piplineWithError() {
Pipeline p = jedis.pipelined();
p.set("foo", "bar");
Response<Set<String>> error = p.smembers("foo");
Response<String> r = p.get("foo");
p.sync();
try {
error.get();
fail();
} catch (JedisDataException e) {
// that is fine we should be here
}
assertEquals(r.get(), "bar");
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method testSyncWithNoCommandQueued.
@Test
public void testSyncWithNoCommandQueued() {
// we need to test with fresh instance of Jedis
Jedis jedis2 = new Jedis(hnp.getHost(), hnp.getPort(), 500);
Pipeline pipeline = jedis2.pipelined();
pipeline.sync();
jedis2.close();
jedis2 = new Jedis(hnp.getHost(), hnp.getPort(), 500);
pipeline = jedis2.pipelined();
List<Object> resp = pipeline.syncAndReturnAll();
assertTrue(resp.isEmpty());
jedis2.close();
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method canRetrieveUnsetKey.
@Test
public void canRetrieveUnsetKey() {
Pipeline p = jedis.pipelined();
Response<String> shouldNotExist = p.get(UUID.randomUUID().toString());
p.sync();
assertNull(shouldNotExist.get());
}
Aggregations