Using Response Object in Jedis, throws ClassCastException . I am not able to get any value from Redis when I use pipeline. Please help. I am using Jedis 2.1.0
public class JedisPipeline {
public static void main(String args[]){
final JedisPool pool = new JedisPool(new JedisPoolConfig(), "127.0.0.1", 6379);
Jedis jedis = pool.getResource();
Pipeline pipeline = jedis.pipelined();
pipeline.multi();
HashMap<String,String> map = new HashMap<String,String>();
map.put("50", "50");
pipeline.hmset("Id",map);
Response <Long> incr = pipeline.hincrBy("Id", "100", 100);
Response<Map<String,String>> map1 = pipeline.hgetAll("Id");
pipeline.exec();
List<Object> results = pipeline.syncAndReturnAll();
System.out.println(results);
System.out.println( incr.get());
System.out.println( map1.get());
pool.returnResource(jedis);
pool.destroy();
}
}
Exception in thread "main" java.lang.ClassCastException: [B cannot be cast to java.lang.Long
at redis.clients.jedis.BuilderFactory$4.build(BuilderFactory.java:45)
at redis.clients.jedis.BuilderFactory$4.build(BuilderFactory.java:48)
at redis.clients.jedis.Response.get(Response.java:27)
at redis.clients.jedis.Pipeline.syncAndReturnAll(Pipeline.java:42)
at com.work.jedis.JedisPipeline.main(JedisPipeline.java:28)
There was a conflict in the jar files I used. I have kept both jedis 2.1.0 and jedis 2.0.0 by mistake in the build path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With