D
D
DYLAN2020-01-29 17:56:05
opencart
DYLAN, 2020-01-29 17:56:05

How to implement automatic caching in the Bitrix component?

How to implement automatic caching in custom Bitrix components?
On the D7 core, components are inherited from the CBitrixComponent class, which implements the StartResultCache, EndResultCache, and AbortResultCache methods.

The signature of the StartResultCache method call does not imply some place for cache tagging, etc., how then to implement automatic cache clearing when updating elements (or categories) in the infoblock?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
smilingcheater, 2020-01-29
@ermolaev_nikita

To mark the component cache with the infoblock dependency tag - inside the cached part (StartResultCache block) call:

$taggedCache = \Bitrix\Main\Application::getInstance()->getTaggedCache();
$taggedCache->registerTag('iblock_id_' . $iblockId);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question