Bitrix Site Manager


 int cacheTime [,
 string additionalCacheID [,
 string cachePath]]]

This helper method is used by components for internal caching.

If the cache is valid, the method displays its contents, fills in $arResult and returns False. If the cache is not valid, the method returns True, caching completes and the cache is saved when calling CBitrixComponent::IncludeComponentTemplate or CBitrixComponent::ShowComponentTemplate upon including the component template.


Parameter Description
cacheTime Cache valid period, in seconds. If the parameter is false, the period is taken from the $arParams["CACHE_TIME"] input parameter.
additionalCacheID The cache depends on the current site (SITE_ID), component name, path to the file and input parameters $arParams.

If there are any other parameters on which the cache should depend, they must be specified here as a string. By default, the parameter is false which means that the cache only depends on the current site SITE_ID, component name, path to the file and input parameters $arParams.
cachePath Path to the cache file relative to the cache folder. By default -  "/".SITE_ID.<path to the component relative to bitrix/components>.

Return Values

Returns true on success, or false otherwise.


// Check and initialize input parameters
if ($arParams["ID"] <= 0)
    $arParams["ID"] = 10;

// If there is no valid cache, query data and
// a valid cache is to be created
if ($this->StartResultCache())
    // Query data and fill in $arResult
    $arResult = array(
        "ID" => rand(1, 100)

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

    // If any condition is true,
    // it is not necessary to cache data
    if ($arParams["ID"] < 10)

    // Include output template

// Set the page title using the delay
// function

// cache has to depend on user groups 
// where the user is a member if ($this->StartResultCache(false, $USER->GetGroups())) { // There is no valid cache.
   // Fetch data from the data base into // $arResult }

See Also

  • CBitrixComponent::AbortResultCache
  • CBitrixComponent::ClearResultCache