Redis client 2.0.0 pipeline list rpop bug, redisrpop

Source: Internet
Author: User

Redis client 2.0.0 pipeline list rpop bug, redisrpop

Description:

The rpop of the list OF redis client 2.0.0 pipeline has a serious bug. When the rpop list is used, if the list is already empty, the Response from rpop is still not null, causing the listresponse to be suspended. the get () method throws an exception.


Code:

@Testpublic void testRedisPipeline(){    Jedis jedis = null;    try{        jedis = new Jedis("127.0.0.1",6379);        Pipeline pipelined = jedis.pipelined();        for(int i=200;i<10000;i++){            pipelined.lpush("aa", "val"+i);        }        pipelined.sync();            }catch(Exception e){        e.printStackTrace();    }finally{        if(jedis!=null){            jedis.disconnect();        }    }}
<Span style = "white-space: pre"> </span> // This method causes redis qps to rise infinitely @ Testpublic void testRedisPipelinePop () {Jedis jedis = null; try {List <Response <String> result = new ArrayList <Response <String> (); jedis = new Jedis ("127.0.0.1", 6379); Pipeline pipelined = jedis. pipelined (); for (int I = 0; I <10; I ++) {// System. out. println (I); Response <String> rpop = pipelined. rpop ("aa"); // System. out. println (rpop); result. add (Rpop);} pipelined. sync (); // Response <Long> r = pipelined. bitcount ("aa"); for (Response <String> response: result) {System. out. println (response. get (); // Exception} catch (Exception e) {e. printStackTrace ();} finally {if (jedis! = Null) {jedis. disconnect ();}}}




Solution:

Use redis-cli 2.1.0 or later

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.