30 if (!isset($this->cacheTag[$path]))
32 $this->cacheTag[$path] = [];
34 $con = Main\Application::getConnection();
35 $sqlHelper = $con->getSqlHelper();
37 $this->pool->useMasterOnly(
true);
42 WHERE SITE_ID = '".$sqlHelper->forSql(SITE_ID, 2).
"'
43 AND CACHE_SALT = '".$sqlHelper->forSql($this->salt, 4).
"'
44 AND RELATIVE_PATH = '".$sqlHelper->forSql($path).
"'
47 while ($ar = $rs->fetch())
49 $this->cacheTag[$path][$ar[
"TAG"]] =
true;
52 $this->pool->useMasterOnly(
false);
75 $this->pool->useMasterOnly(
true);
77 $con = Main\Application::getConnection();
78 $sqlHelper = $con->getSqlHelper();
81 $siteIdForSql = $sqlHelper->forSql(SITE_ID, 2);
85 INSERT ".($this->isMySql ?
"IGNORE":
"").
" INTO b_cache_tag (SITE_ID, CACHE_SALT, RELATIVE_PATH, TAG)
88 $maxValuesLen = $this->isMySql ? 2048: 0;
91 foreach ($this->compCacheStack as $arCompCache)
93 $path = $arCompCache[0];
97 $sqlRELATIVE_PATH = $sqlHelper->forSql($path, 255);
99 $sql =
",\n('".$siteIdForSql.
"', '".$cacheSaltForSql.
"', '".$sqlRELATIVE_PATH.
"',";
101 foreach ($arCompCache[1] as $tag => $t)
103 if (!isset($this->cacheTag[$path][$tag]))
105 $strSqlValues .= $sql.
" '".$sqlHelper->forSql($tag, 100).
"')";
106 if (mb_strlen($strSqlValues) > $maxValuesLen)
108 $con->queryExecute($strSqlPrefix.mb_substr($strSqlValues, 2));
111 $this->cacheTag[$path][$tag] =
true;
116 if ($strSqlValues <>
'')
118 $con->queryExecute($strSqlPrefix.mb_substr($strSqlValues, 2));
121 $this->pool->useMasterOnly(
false);
124 array_shift($this->compCacheStack);
143 $this->pool->useMasterOnly(
true);
145 $con = Main\Application::getConnection();
146 $helper = $con->getSqlHelper();
150 $where =
" WHERE TAG <> '*'";
154 $where =
" WHERE TAG = '".$helper->forSql($tag).
"'";
158 $rs = $con->query(
"SELECT ID, RELATIVE_PATH FROM b_cache_tag".$where);
159 while ($ar = $rs->fetch())
161 $dirs[$ar[
"RELATIVE_PATH"]][] = $ar[
"ID"];
164 $con->queryExecute(
"DELETE FROM b_cache_tag".$where);
166 $max_length = 102400;
167 $sql =
"DELETE FROM b_cache_tag WHERE ID in (%s)";
168 $where_list = array();
171 foreach ($dirs as $path => $ar)
173 $cache->cleanDir($path);
174 unset($this->cacheTag[$path]);
176 foreach ($ar as $cacheTagId)
178 $where = intval($cacheTagId);
179 $length += mb_strlen($where) + 1;
180 $where_list[] = $where;
181 if ($length > $max_length)
183 $con->queryExecute(sprintf($sql, implode(
",", $where_list)));
184 $where_list = array();
192 $con->queryExecute(sprintf($sql, implode(
",", $where_list)));
195 $this->pool->useMasterOnly(
false);