public function setDebug($debug) { if ($debug) { memcache_debug(true); } else { memcache_debug(false); } }
static function connect() { if (!CGlobal::$memcache_connect_id && !AZMemcache::$crashed) { if (!function_exists('memcache_connect')) { //dl("php_memcache.dll"); //dl("php_xdebug.dll"); AZMemcache::$crashed = 1; return FALSE; } AZMemcache::$identifier = MEMCACHE_ID; if (!CGlobal::$memcache_server || !count(CGlobal::$memcache_server)) { AZMemcache::$crashed = 1; return FALSE; } if (DEBUG) { $rtime = microtime(); $rtime = explode(" ", $rtime); $rtime = $rtime[1] + $rtime[0]; $start_rb = $rtime; } for ($i = 0, $n = count(CGlobal::$memcache_server); $i < $n; $i++) { $server = CGlobal::$memcache_server[$i]; if ($i < 1) { CGlobal::$memcache_connect_id = memcache_connect($server['host'], $server['port']); } else { memcache_add_server(CGlobal::$memcache_connect_id, $server['host'], $server['port']); } if (DEBUG) { $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $end_rb = $mtime; $load_time = round($end_rb - $start_rb, 5) . "s"; CGlobal::$conn_debug .= " <b>Connect to Memcache server : {$server['host']} : {$server['port']} </b> [in {$load_time}]<br>\n"; } } if (!CGlobal::$memcache_connect_id) { AZMemcache::$crashed = 1; return FALSE; } if (function_exists('memcache_set_compress_threshold')) { memcache_set_compress_threshold(CGlobal::$memcache_connect_id, 20000, 0.2); } memcache_debug(AZMemcache::$debug); } return CGlobal::$memcache_connect_id; }