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

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

	if ($tag === true)
	{
		$where = " WHERE TAG <> '*'";
	}
	else
	{
		$where = " WHERE TAG = '".$helper->forSql($tag)."'";
	}

	$dirs = [];
	$rs = $con->query("SELECT ID, RELATIVE_PATH FROM b_cache_tag".$where);
	while ($ar = $rs->fetch())
	{
		$dirs[$ar["RELATIVE_PATH"]][] = $ar["ID"];
	}

	$con->queryExecute("DELETE FROM b_cache_tag".$where);

	$max_length = 102400;
	$sql = "DELETE FROM b_cache_tag WHERE ID in (%s)";
	$where_list = array();
	$length = 0;
	$cache = Cache::createInstance();
	foreach ($dirs as $path => $ar)
	{
		$cache->cleanDir($path);
		unset($this->cacheTag[$path]);

		foreach ($ar as $cacheTagId)
		{
			$where = intval($cacheTagId);
			$length += mb_strlen($where) + 1;
			$where_list[] = $where;
			if ($length > $max_length)
			{
				$con->queryExecute(sprintf($sql, implode(",", $where_list)));
				$where_list = array();
				$length = 0;
			}
		}
	}

	if ($where_list)
	{
		$con->queryExecute(sprintf($sql, implode(",", $where_list)));
	}

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