• Модуль: cluster
  • Путь к файлу: ~/bitrix/modules/cluster/classes/general/memcache.php
  • Класс: CClusterMemcache
  • Вызов: CClusterMemcache::CheckFields
function CheckFields(&$arFields, $ID)
{
	global $APPLICATION;
	$aMsg = array();

	if(isset($arFields["PORT"]))
		$arFields["PORT"] = intval($arFields["PORT"]);

	if(isset($arFields["WEIGHT"]) || $ID === false)
	{
		$weight = intval($arFields["WEIGHT"]);
		if($weight < 0)
			$weight = 0;
		elseif($weight > 100)
			$weight = 100;
		$arFields["WEIGHT"] = $weight;
	}

	if(isset($arFields["HOST"]) && isset($arFields["PORT"]))
	{
		$ob = new Memcache;
		if(!@$ob->connect($arFields["HOST"], $arFields["PORT"]))
			$aMsg[] = array("id" => "HOST", "text" => GetMessage("CLU_MEMCACHE_CANNOT_CONNECT"));
	}

	if(!empty($aMsg))
	{
		$e = new CAdminException($aMsg);
		$APPLICATION->ThrowException($e);
		return false;
	}
	return true;
}