Memcached validation server on the network

I use the php memcached extension , when you start addServerthe documentation says that the connection is not established on the server, so if the memcached server is working, it will still be added.

How to check if the server is accessible? Using memcached, not a memcache extension, so I cannot use getServerStatus.

+3
source share
2 answers

You can use getStats to check the statistics of your servers:

<?php
$m = new Memcached();
$m->addServer('localhost', 11211);

print_r($m->getStats());
?>
+3
source

In the answer above, if PID -1 is returned in the statistics array, the server is turned off, any other is turned on.

+1
source

All Articles