废话不多说,直接上源码:
报错前的代码:
Pipeline pipeline= jedis.pipelined();
Set set=new LinkedHashSet();
Response> response= pipeline.keys("aritst:*:id");
pipeline.exec();
set=response.get();
System.out.println(set.size());
执行后报错如下:
Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: Please close pipeline or multi block before calling this method.
at redis.clients.jedis.Response.get(Response.java:23)
后来在网上查找了一些资料,发现将pipeline.exec();修改成pipeline.sync();就可以!!
至于什么原因就不知道,希望看到文章的同志发表一下观点,谢谢!!
报错前的代码:
Pipeline pipeline= jedis.pipelined();
Set set=new LinkedHashSet();
Response> response= pipeline.keys("aritst:*:id");
pipeline.exec();
set=response.get();
System.out.println(set.size());
执行后报错如下:
Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: Please close pipeline or multi block before calling this method.
at redis.clients.jedis.Response.get(Response.java:23)
后来在网上查找了一些资料,发现将pipeline.exec();修改成pipeline.sync();就可以!!
至于什么原因就不知道,希望看到文章的同志发表一下观点,谢谢!!
本文介绍了一个关于使用Redis Pipeline时出现的异常:'Please close pipeline or multiblock before calling this method.',并提供了解决方案,即将pipeline.exec()替换为pipeline.sync()。
720

被折叠的 条评论
为什么被折叠?



