Replies: 5 comments 5 replies
-
So after looking into the code, I think this is the correct way.
We check if there exists a connection, if so we will use that Pool in the newly instantiated JedisPooled object. In the DefaultCommandExecutor, in the try-with-resource block, the connection is closed, i.e. returned back to the pool.
This would answer my question. |
Beta Was this translation helpful? Give feedback.
-
Hey @dbeken85 unfortunately, I, too, have a hard time comprehending how JedisPooled is supposed to be used. Do I have to initialize a connection pool as a singleton/static object and then pass this to the JedisPooled constructor? |
Beta Was this translation helpful? Give feedback.
-
I'm also facing this doubt. I did like this:
But the doubts remain, is it the right approach for my usecase? Does the JedisPooled get a connection from the pool every time its methods are called and then releases it when done automatically? |
Beta Was this translation helpful? Give feedback.
-
Apologies everyone. For some reasons I was unsubscribed from this discussion.
Yes. BTW, availability of a connection in the pool is controlled by ConnectionPoolConfig.
No, you don't have to (but you can).
Which constructor argument?
Yes.
No. |
Beta Was this translation helpful? Give feedback.
-
Hi @sazzad16 and @dbeken85 , does this JedisPooled is reliable for multi-threaded applications? can we use Single JedisPooled instance for all threads? can we rely on it to handle the connections and object pool handling by itself? in case of connection loss, do we have to do anything in order to handle pools for Jedis objects and connections? |
Beta Was this translation helpful? Give feedback.
-
Hello all,
I am repeating this question as a mail, so if it is a duplicate, please excuse me.
I want to use JSON as a Jedis request. I do not have multiple transactions, so I do not want to use pipeline or transaction.
I am reading that JedisPooled is a simplified version of JedisPool, and recommended, but I can find not a single worthy documentation on how to use it. JedisPooled and UnifiedJedis is needed for JSON.
I have a multithreaded scenario, where I do want to reuse a connection pool. I do not want to create a new connection for each request.
The "old" way:
1- Initiate JedisPool once
2- Assume, we have a method which sends JSON Data:
Create a Jedis Object inside a try-with-resource block (but Jedis has no Autoclose, so how does this even work??), for every thread calling this method.
3- Call .close() on the jedis, once the message has been sent.
How do we do this with UnifiedJedis and JedisPooled
I am getting frustrated by the lack of documentation and the lack of comments in the code.
Best Regards,
Dincer
Beta Was this translation helpful? Give feedback.
All reactions