I am using memcached
, and use Java spymemcache
to connect to it.
My question is:
Does MemcachedClient
has a built-in connection pool?
Can I reuse instance of the class for concurrent operation on memcached, or I need to create a new instance each time I need it?
From the documentation:
Each MemcachedClient instance establishes and maintains a single connection to each server in your cluster.
There is only one thread for all processing. Regardless of the number of requests, threads using the client, or servers to which the client is connected, only one thread will ever be allocated to a given MemcachedClient.
More details can be found here https://code.google.com/p/spymemcached/wiki/Optimizations.
In one of our projects, to implement connection pooling, we initialized a List(size 50) of MemcachedClient and used one of them randomly while making a get or put call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With