Is it necessary to use jedis.close()

僤鯓⒐⒋嵵緔 提交于 2020-01-14 02:55:24

问题


Hi I am new in implementing the java code, Tried the following things:-

I am using jedis as redis java client-library, I have made the jedis object and used its api to print the redis information, but this all is done inside the method, So my doubt is "should I use jedis.close() to close the client connection in my code"

    class Information{

        public void redisdetails(){

        Jedis jedis = new Jedis("localhost", 6379));

                Map<String, Object> info = new HashMap<>();

                info.put("server", jedis.info("server"));
                info.put("memory", jedis.info("memory"));
                info.put("clients", jedis.info("clients"));
                info.put("stats", jedis.info("stats"));


        }
}

because the jedis object is been created inside the redisdetails method, so object will automatically destroyed or i need to write jedis.close() and if yes then why?

来源:https://stackoverflow.com/questions/54902337/is-it-necessary-to-use-jedis-close

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!