A
A
Anton2021-10-17 16:37:08
1C-Bitrix
Anton, 2021-10-17 16:37:08

Why is the cache not being read from the file, crashes with an error Page not available?

It used to work, but at some point it stopped working.

<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
   $APPLICATION->SetTitle("Продажи");
   $MAINUSER = '3'; 
   CModule::IncludeModule('highloadblock');
   use Bitrix\Highloadblock\HighloadBlockTable as HLBT;
   //Функция получения экземпляра класса:
   function GetEntityDataClass($HlBlockId) 
   {
       if (empty($HlBlockId) || $HlBlockId < 1){return false;}
       $hlblock = HLBT::getById($HlBlockId)->fetch();
       $entity = HLBT::compileEntity($hlblock);
       $entity_data_class = $entity->getDataClass();
       return $entity_data_class;
   };
   $arFilter = Array("UF_USER"=>$MAINUSER);
   //Запросим продажи
   $SalesData = GetEntityDataClass(4)::getList(array(
      'select' => array('*'),
      'filter' => $arFilter
   ));
   // Кешируем запросы
   use \Bitrix\Main\Data\Cache;
   $obCache = new CPHPCache();
   $cacheLifetime = 600; $cacheID = 'sales'.$MAINUSER; $cachePath = '/'.$cacheID;

   if( $obCache->InitCache($cacheLifetime, $cacheID, $cachePath) )
   {
      $vars = $obCache->GetVars();
      extract($vars); 
   }
   elseif( $obCache->StartDataCache()  )
   {
   while($el = $SalesData->fetch()){$sales[] = $el;};
   $obCache->EndDataCache(array('sales' => $sales));
   };
.......

Removing some code from
// Кешируем запросы
   use \Bitrix\Main\Data\Cache;
   $obCache = new CPHPCache();
   $cacheLifetime = 600; $cacheID = 'sales'.$MAINUSER; $cachePath = '/'.$cacheID;

   if( $obCache->InitCache($cacheLifetime, $cacheID, $cachePath) )
   {
      $vars = $obCache->GetVars();
      extract($vars); 
   }
   elseif( $obCache->StartDataCache()  )
   {
   while($el = $SalesData->fetch()){$sales[] = $el;};
   $obCache->EndDataCache(array('sales' => $sales));
   };

By doing this:
// Кешируем запросы
   use \Bitrix\Main\Data\Cache;
   $obCache = new CPHPCache();
   $cacheLifetime = 600; $cacheID = 'sales'.$MAINUSER; $cachePath = '/'.$cacheID;

   if( $obCache->StartDataCache()  )
   {
   while($el = $SalesData->fetch()){$sales[] = $el;};
   $obCache->EndDataCache(array('sales' => $sales));
   };

works, i.e. as if it can't read the cache from the file.
The cache file itself is being created, maybe because of its size an error (5 megabytes)? Because the similar code in the other section works.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question