Configure Jedis timeout

前端 未结 3 2069
失恋的感觉
失恋的感觉 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:30

    This is a bit of an extension to xetorthio's answer, but here is similar approach for use with a JedisPool. (Caveat: this is based on my understanding from looking at the Jedis version 2.6.2 code directly and has not been tested in a live use case.)

        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxWaitMillis(writeTimeout);
        JedisPool pool = new JedisPool(jedisPoolConfig, redisHost, port, readTimeout);
    

    The writeTimeout is max time for a Jedis resource from the pool to wait for a write operation.

    The readTimeout specified for the pool constructor is the wait time for a socket read, see java.net.Socket.setSoTimeout for more specific details.

提交回复
热议问题