Documentation

AbortResultCache

void
AbortResultCache();

The method updates support of the component in-built caching. Non-static method.

This method is used if resulting data selection showed no need of caching (if valid cache is unavailable). For example, if there isn't any news item with required ID, caching must be interrupted and message printed informing about the missing news item. If caching is not interrupted, a malicious third-party can increase cache size up to the complete site disk space by calling a page with random (including non-existent) IDs.

Example

// Verification and initialization of input parameters
if ($arParams["ID"] <= 0)
	$arParams["ID"] = 10;

// If no valid cache is available (data must be requested
// and create valid cache)
if ($this->StartResultCache())
{
	// Data query and filling out $arResult
	$arResult = array(
		"ID" => rand(1, 100)
	);

	for ($i = 0; $i < 5; $i++)
		$arResult["FIELDS"][] = rand(1, 100);

	// If a specific condition is met, data caching 
	// is not required
	if ($arParams["ID"] < 10)
		$this->AbortResultCache();

	// Connect display template
	$this->IncludeComponentTemplate();
}

// Set page header with delayed
// function
$APPLICATION->SetTitle($arResult["ID"]); 

See Also

  • CBitrixComponent::StartResultCache
  • CBitrixComponent::ClearResultCache


  • © «Bitrix24», 2001-2022
    Up