Redis之Read timed out

Redis报错:redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out

Problem Description:

        Ali goes on linux server (the cheapest kind of ...), the use of cache implementation redis thumbs up function error, due to redis thought it was not deep enough profile, ignoring the code. .

Exception information:

redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out

at redis.clients.jedis.Protocol.process(Protocol.java:79)
at redis.clients.jedis.Protocol.read(Protocol.java:131)
at redis.clients.jedis.Connection.getIntegerReply(Connection.java:188)
at redis.clients.jedis.Jedis.sismember(Jedis.java:1266)

problem solved:

        Perform close () after you are finished using jedis

Case Study:

public String set(String key, String value) {
        // TODO Auto-generated method stub
        Jedis jedis =jedisPool.getResource();
        String result =jedis.set(key, value);
        jedis.close();
        return result;
    }

    @Override
    public String get(String key) {
        // TODO Auto-generated method stub
        Jedis jedis =jedisPool.getResource();
        String result =jedis.get(key);
        jedis.close();
        return result;
    }

Note: After each use to close out, jedisPool not closed, otherwise it will error, can not access resources

 

 

 

Special thanks to: https: //www.cnblogs.com/williamjie/p/10271575.html

Links: Redis Detailed profile: https: //www.cnblogs.com/cxd4321/archive/2012/12/14/2817669.html

Guess you like

Origin www.cnblogs.com/pamne/p/11886733.html