PHP version: 7.2.6
I have a memcached server running on 127.0.0.1:11211, but not 127.0.0.22:11212.
$memcached = new Memcached;
if( !$memcached->addServer('127.0.0.22', 11212) )
die( 'memcached server error' );
else
echo 'OK';
The actual output is "OK", why is it not ‘memcached server error’? How to determine whether the memcached server is connected?
Expected result:
memcached server error
Actual result:
OK
2
Answers
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.You can test