use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method testDiscardInPipeline.
@Test
public void testDiscardInPipeline() {
Pipeline pipeline = jedis.pipelined();
pipeline.multi();
pipeline.set("foo", "bar");
Response<String> discard = pipeline.discard();
Response<String> get = pipeline.get("foo");
pipeline.sync();
discard.get();
get.get();
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method pipelineWithPubSub.
@Test
public void pipelineWithPubSub() {
Pipeline pipelined = jedis.pipelined();
Response<Long> p1 = pipelined.publish("foo", "bar");
Response<Long> p2 = pipelined.publish("foo".getBytes(), "bar".getBytes());
pipelined.sync();
assertEquals(0, p1.get().longValue());
assertEquals(0, p2.get().longValue());
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method testEvalshaKeyAndArgWithBinary.
@Test
public void testEvalshaKeyAndArgWithBinary() {
byte[] bKey = SafeEncoder.encode("test");
byte[] bArg = SafeEncoder.encode("3");
String script = "redis.call('INCRBY', KEYS[1], ARGV[1]) redis.call('INCRBY', KEYS[1], ARGV[1])";
byte[] bScript = SafeEncoder.encode(script);
byte[] bSha1 = jedis.scriptLoad(bScript);
assertTrue(jedis.scriptExists(bSha1) == 1);
Pipeline p = jedis.pipelined();
p.set(bKey, SafeEncoder.encode("0"));
Response<Object> result0 = p.evalsha(bSha1, Arrays.asList(bKey), Arrays.asList(bArg));
p.incr(bKey);
Response<Object> result1 = p.evalsha(bSha1, Arrays.asList(bKey), Arrays.asList(bArg));
Response<byte[]> result2 = p.get(bKey);
p.sync();
assertNull(result0.get());
assertNull(result1.get());
assertArrayEquals(SafeEncoder.encode("13"), result2.get());
}
use of redis.clients.jedis.Pipeline in project cachecloud by sohutv.
the class PipeliningTest method pipelineResponseWithData.
@Test
public void pipelineResponseWithData() {
jedis.zadd("zset", 1, "foo");
Pipeline p = jedis.pipelined();
Response<Double> score = p.zscore("zset", "foo");
p.sync();
assertNotNull(score.get());
}
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();
}
Aggregations