Configure Jedis timeout

前端 未结 3 2076
失恋的感觉
失恋的感觉 2020-12-31 12:50

I\'m having problems completing an .hgetall(), here\'s what I\'ve tried:

Jedis jedis = new Jedis(REDIS_MASTER_NODE);
jedis.connect();
jedis.conf         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-31 13:41

    If what you want to do is set Jedis connection timeout, you should do it using the special constructor made for that:

    public Jedis(final String host, final int port, final int timeout)
    

    What you are doing is setting the timeout on redis settings from jedis. Doing CONFIG SET timeout 60, means that redis will close idle client connections after 60 seconds. That's why you get the exception in Jedis.

提交回复
热议问题