I believe the answer to both questions in this case is to enable
consistent hashing.
On 1/6/10 10:44 PM, Martin Bay wrote:
What if I save key1=val1 using PHP functions addServer() and set(),
and later want to fetch that value from perl? How do I know which
memcached server to connect to?
I believe (someone correct me otherwise) that PHP (pecl/memcached) and
Perl both use the same consistent hashing algorithm. PECL/memcached
actually gives you several choices for the hashing algorithm. Other
libmmecached based clients will play nice with PECL/memcached. Now, you
will have issues when storing complex data like arrays/objects as each
language will need to serialize that data in a native format.
What if I save 1000000 values to 3 memcached servers, and then decide
to add a 4th server? The keyhash>server will not match compared to the
3 server setup.
Consistent hashing uses a hashed wheel concept. Using this hashing
system vastly reduce (not 100% eliminate) the cache/key realignment
caused by adding/removing nodes.
Brian.
--------
http://brian.moonspot.net/