killme2008 / xmemcached

High performance, easy to use multithreaded memcached client in java.
http://fnil.net/xmemcached
Apache License 2.0
757 stars 280 forks source link

NIO Connection Pooling - synchronzation #67

Closed adrianbader closed 7 years ago

adrianbader commented 7 years ago

In the Wiki, there is written

XMemcached is base on java NIO, it has one connection to one Memcached server by default, it is very excellent in most projects. But in some typical high-concurrent enviornment, it will has bottleneck too. So Xmemcached support NIO connection pool, it can create multiple connections to one Memcached server. But you should know, they are not synchronized, so you must make sure the synchronzation of data update. You can enable connection pool with following code:

I do not understand this: ...But you should know, they are not synchronized, so you must make sure the synchronzation of data update... In which situation is a synchronisation needed and why? Thank you for your help!

killme2008 commented 7 years ago

The doc does not make sense here, i will remove it.

The real meaning here is that if you put an item into memcached in thread A with connection A, and you want to get the item in thread B with connection B concurrently, these two operations are not synchronized. If you want B operation fetching the item successfully, you should make sure that B operation happens after A operation.

adrianbader commented 7 years ago

Thank you for the explanation! I fully agree.