I have a memcached server running on 127.0.0.1:11211
, but not 127.0.0.22:11212
. I would like to test the connection to it thanks to this code;
$memcached = new Memcached;
if( !$memcached->addServer('127.0.0.22', 11212) )
die( 'memcached server error' );
else
echo 'OK';
The actual output is 'OK' instead of the expected 'memcached server error'
How to determine whether the memcached server is connected?
The memcache client will not make a connection to a server unless you're reading/writing to it. addServer
returning true just means that the server is added to the pool, but it doesn't imply that a connection can be made.