What I am trying to do is some sort of failover in case one memcached
fails. My testing code is below.
What I have expected to see is to have the requests going to the other
server if one drops out. However, when I start this script with both
servers up, the request are going to the first one. When I kill that
memcached-server, it keeps on trying to use the first server, and
never uses the second.
What do I need to do to get one server out of the pool if it is gone?
Thanks a lot!
<?php
$m = new Memcached();
$m->addServer('192.168.0.248', 11211);
$m->addServer('192.168.0.249', 11211);
$m-
>setOption(Memcached::OPT_DISTRIBUTION,Memcached::DISTRIBUTION_CONSISTENT);
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$m->setOption(Memcached::OPT_SERVER_FAILURE_LIMIT, 5);
while(1){
$m->set('1234','ojcojo');
$lala=$m->get('1234');
echo("$lala \n");
sleep(1);
}