use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method testReuseJedisWhenPipelineIsEmpty.
@Test
public void testReuseJedisWhenPipelineIsEmpty() {
Pipeline pipeline = jedis.pipelined();
pipeline.set("foo", "3");
pipeline.sync();
String result = jedis.get("foo");
assertEquals(result, "3");
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method testResetStateWhenInPipeline.
@Test
public void testResetStateWhenInPipeline() {
Pipeline pipeline = jedis.pipelined();
pipeline.set("foo", "3");
jedis.resetState();
String result = jedis.get("foo");
assertEquals(result, "3");
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method testEvalshaKeyAndArg.
@Test
public void testEvalshaKeyAndArg() {
String key = "test";
String arg = "3";
String script = "redis.call('INCRBY', KEYS[1], ARGV[1]) redis.call('INCRBY', KEYS[1], ARGV[1])";
String sha1 = jedis.scriptLoad(script);
assertTrue(jedis.scriptExists(sha1));
Pipeline p = jedis.pipelined();
p.set(key, "0");
Response<Object> result0 = p.evalsha(sha1, Arrays.asList(key), Arrays.asList(arg));
p.incr(key);
Response<Object> result1 = p.evalsha(sha1, 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 testEvalsha.
@Test
public void testEvalsha() {
String script = "return 'success!'";
String sha1 = jedis.scriptLoad(script);
assertTrue(jedis.scriptExists(sha1));
Pipeline p = jedis.pipelined();
Response<Object> result = p.evalsha(sha1);
p.sync();
assertEquals("success!", result.get());
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method testEvalNestedListsWithBinary.
@Test
public void testEvalNestedListsWithBinary() {
byte[] bScript = SafeEncoder.encode("return { {KEYS[1]} , {2} }");
byte[] bKey = SafeEncoder.encode("key1");
Pipeline p = jedis.pipelined();
Response<Object> result = p.eval(bScript, 1, bKey);
p.sync();
List<?> results = (List<?>) result.get();
assertThat((List<byte[]>) results.get(0), listWithItem(bKey));
assertThat((List<Long>) results.get(1), listWithItem(2L));
}
Aggregations