• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/data/taggedcache.php
  • Класс: BitrixMainDataTaggedCache
  • Вызов: TaggedCache::endTagCache
public function endTagCache()
{
	$this->initCompSalt();

	if ($this->wasTagged)
	{
		$this->pool->useMasterOnly(true);

		$con = MainApplication::getConnection();
		$sqlHelper = $con->getSqlHelper();

		// TODO: SITE_ID
		$siteIdForSql = $sqlHelper->forSql(SITE_ID, 2);
		$cacheSaltForSql = $this->salt;

		$strSqlPrefix = "
			INSERT ".($this->isMySql ? "IGNORE": "")." INTO b_cache_tag (SITE_ID, CACHE_SALT, RELATIVE_PATH, TAG)
			VALUES
		";
		$maxValuesLen = $this->isMySql ? 2048: 0;
		$strSqlValues = "";

		foreach ($this->compCacheStack as $arCompCache)
		{
			$path = $arCompCache[0];
			if ($path <> '')
			{
				$this->initDbCache($path);
				$sqlRELATIVE_PATH = $sqlHelper->forSql($path, 255);

				$sql = ",n('".$siteIdForSql."', '".$cacheSaltForSql."', '".$sqlRELATIVE_PATH."',";

				foreach ($arCompCache[1] as $tag => $t)
				{
					if (!isset($this->cacheTag[$path][$tag]))
					{
						$strSqlValues .= $sql." '".$sqlHelper->forSql($tag, 100)."')";
						if (mb_strlen($strSqlValues) > $maxValuesLen)
						{
							$con->queryExecute($strSqlPrefix.mb_substr($strSqlValues, 2));
							$strSqlValues = "";
						}
						$this->cacheTag[$path][$tag] = true;
					}
				}
			}
		}
		if ($strSqlValues <> '')
		{
			$con->queryExecute($strSqlPrefix.mb_substr($strSqlValues, 2));
		}

		$this->pool->useMasterOnly(false);
	}

	array_shift($this->compCacheStack);
}