Whats the use of connect() method in jedis ? I can insert and fetch key value pairs by just creating an object,even without calling the connect() method on the object.
jedis = new Jedis("localhost", 6379);
Whats the use of connect() method in jedis ? I can insert and fetch key value pairs by just creating an object,even without calling the connect() method on the object.
jedis = new Jedis("localhost", 6379);
Unfortunatelly there is no comments / documentation to the function to be found, which would explain if it’s necessary or not, …
It seems to me that the Jedis client would connect automatically the first time you send a command, not when you initialize the class. However if you want it to be already connected beforehand you can initialize the connection manually with the connect
method, as well as close it manually with disconnect
.
Sometimes initializing a connection might take too much time, in this case, if you’d have a pool of Jedsi
-objects, you want them to be already connected to the server, before other threads can take them from the pool and not leave the connection initialization to the threads themselves.