I'm using php memcached (not memcache) but I have a problem about failover.
For example, I had two servers of memcached but when one of server crash I want that memcached continue to operate with just one.
With lib memcache that works but not with memcached. I tried something like that
<?php
$m = new Memcached();
$m->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT);
$m->addServer('server1', 11211);
$m->addServer('server2', 11211);
var_dump($m->set('1234','test'));
var_dump($m->get('1234'));
$m->flush();
$m = new Memcache();
$m->addServer('server1', 11211);
$m->addServer('server2', 11211);
var_dump($m->set('1234','test'));
var_dump($m->get('1234'));
$m->flush();
?>
When both memcached are up:
bool(true)
string(4) "test"
bool(true)
string(4) "test"
But when I stop server2:
bool(false)
bool(false)
Notice: MemcachePool::set(): Server server2 (tcp 11211, udp 0) failed with: Connection refused (111) in /root/memcached.php on line 22
Call Stack:
0.0013 637584 1. {main}() /root/memcached.php:0
0.0220 653104 2. MemcachePool->set() /root/memcached.php:22
bool(true)
string(4) "test"
On memcached the IO are directly blocked and return false whereas on memcache there is a notice but IO works.
PS: I tried setOption(Memcached::OPT_DISTRIBUTION,Memcached::DISTRIBUTION_CONSISTENT);
but does not work