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?