Answer the question
In order to leave comments, you need to log in
Why doesn't CPHPCache caching work?
Help me understand why caching to the InitCache methods of the CPHPCache class does not work. I tried to cache the output of the list of infoblocks from the database, but I noticed that caching does not work at all. More precisely, the InitCache method does not work. It always returns false What could be the reason?
Here I have a very simple code to check the operation of the caching class, it shows that caching is not happening.
$cache_id = serialize($arParams);
$obCache = new CPHPCache;
if ($obCache->InitCache(3600, $cache_id, '/')) { // тянем данные если они есть
$arResult = $obCache->GetVars();
}
elseif ($obCache->StartDataCache()) { // иначе запишем для того, чтобы следующий раз получить
$arResult = rand(0,100);
$obCache->EndDataCache($arResult);
}
var_dump($arResult);
Answer the question
In order to leave comments, you need to log in
Change the third parameter (instead of / the name of the 'randnumbers' directory). Here is the dock in more detail: https://dev.1c-bitrix.ru/api_d7/bitrix/main/data/c...
Disabled component caching. If you have the cache in the component enabled, then there is no point in additional caching inside.
Make sure you don't have ?clear_cache=Y in your request
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question