ITeye博客

redis的Pipeline使用

boss5518831534 · 2012-05-23 15:32 · redis · 数据库 · Markdown

废话不多说,直接上源码: 报错前的代码: 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();就可以!! 至于什么原因就不知道,希望看到文章的同志发表一下观点,谢谢!!

评论(4)

  1. #4 楼 · boss5518831534 · 2013-03-01 12:05

    嗯,了解。谢谢2楼的朋友

  2. #3 楼 · aashenge · 2013-01-14 15:00

    **"aashenge"exec ** writes:

    表示在事务中,必须有muti才能够使用exec

    敲错 有multi才能够使用exec

  3. #2 楼 · aashenge · 2013-01-14 14:54

    exec 表示在事务中,必须有muti才能够使用exec

  4. #1 楼 · fuchao01 · 2012-06-13 17:59

    关注一下!!!

评论功能维护中,当前仅展示历史评论。