You are here

function sendMemcacheCommand in Production check & Production monitor 6

Same name and namespace in other branches
  1. 7 includes/prod_check.memcache.inc \sendMemcacheCommand()
3 calls to sendMemcacheCommand()
dumpCacheSlab in includes/prod_check.memcache.inc
flushServer in includes/prod_check.memcache.inc
sendMemcacheCommands in includes/prod_check.memcache.inc

File

includes/prod_check.memcache.inc, line 77

Code

function sendMemcacheCommand($server, $port, $command) {
  $s = @fsockopen($server, $port);
  if (!$s) {
    die("Cant connect to:" . $server . ':' . $port);
  }
  fwrite($s, $command . "\r\n");
  $buf = '';
  while (!feof($s)) {
    $buf .= fgets($s, 256);
    if (strpos($buf, "END\r\n") !== false) {

      // stat says end
      break;
    }
    if (strpos($buf, "DELETED\r\n") !== false || strpos($buf, "NOT_FOUND\r\n") !== false) {

      // delete says these
      break;
    }
    if (strpos($buf, "OK\r\n") !== false) {

      // flush_all says ok
      break;
    }
  }
  fclose($s);
  return parseMemcacheResults($buf);
}