4

I am using the memcached php extension, when you run addServer the documentation says no connection is established to the server, so if a memcached server goes down it would still get added.

How can I check that the server is available? Using memcached and not memcache extension so I can't use getServerStatus.

2 Answers 2

4

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

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

print_r($m->getStats());
?>
1
  • if the server was down would it not appear in the key of the getStats returned array?
    – fire
    Commented May 26, 2011 at 15:38
1

In the answer above if in the array of stats return PID -1 the server is down, any other is on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.