function CPHPCacheMemcache() { if (!is_object(self::$obMemcache)) { self::$obMemcache = new Memcache(); $arServerList = CPHPCacheMemcacheCluster::LoadConfig(); if (count($arServerList) == 1) { $arServer = array_pop($arServerList); self::$obMemcache->connect($arServer["HOST"], $arServer["PORT"]); } else { foreach ($arServerList as $arServer) { self::$obMemcache->addServer($arServer["HOST"], $arServer["PORT"], true, $arServer["WEIGHT"] > 0 ? $arServer["WEIGHT"] : 1, 1); } } } if (defined("BX_CACHE_SID")) { $this->sid = BX_MEMCACHE_CLUSTER . BX_CACHE_SID; } else { $this->sid = BX_MEMCACHE_CLUSTER; } if (defined("BX_CLUSTER_GROUP")) { $this->bQueue = true; } }
function _new_cache_object() { static $cache_type = false; if ($cache_type === false) { $isOK = false; if (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/cluster/memcache.php")) { include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/cluster/memcache.php"; if (defined("BX_MEMCACHE_CLUSTER") && extension_loaded('memcache')) { include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/cluster/classes/general/memcache_cache.php"; $obCache = new CPHPCacheMemcacheCluster(); if ($obCache->IsAvailable()) { $cache_type = "CPHPCacheMemcacheCluster"; $isOK = true; } } } //There is no cluster configuration if ($cache_type === false) { if (defined("BX_CACHE_TYPE")) { switch (BX_CACHE_TYPE) { case "memcache": case "CPHPCacheMemcache": if (extension_loaded('memcache') && defined("BX_MEMCACHE_HOST")) { include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache_memcache.php"; $cache_type = "CPHPCacheMemcache"; } break; case "eaccelerator": case "CPHPCacheEAccelerator": if (extension_loaded('eaccelerator')) { include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache_eaccelerator.php"; $cache_type = "CPHPCacheEAccelerator"; } break; case "apc": case "CPHPCacheAPC": if (extension_loaded('apc')) { include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache_apc.php"; $cache_type = "CPHPCacheAPC"; } break; default: if (defined("BX_CACHE_CLASS_FILE") && file_exists(BX_CACHE_CLASS_FILE)) { include_once BX_CACHE_CLASS_FILE; $cache_type = BX_CACHE_TYPE; } break; } } else { include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache_files.php"; $cache_type = "CPHPCacheFiles"; } } //Probe the cache backend class if (!$isOK && class_exists($cache_type)) { $obCache = new $cache_type(); if ($obCache instanceof ICacheBackend) { $isOK = $obCache->IsAvailable(); } } //Bulletproof files cache if (!$isOK) { include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache_files.php"; $cache_type = "CPHPCacheFiles"; } } $cache = new $cache_type(); return $cache; }