Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spymemcache - Does MemcachedClient has a built-in connection pool?

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?

like image 735
user218867 Avatar asked Oct 20 '22 12:10

user218867


1 Answers

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.

like image 89
Ankur Choudhary Avatar answered Oct 22 '22 02:10

Ankur Choudhary