Documentation

Cache

Cache is a final class for PHP caching and the script HTML result. Its querying is almost identical to the class CPHPCache of the old core.

Method Description Available from version
forceRewriting Sets TTL ignore mode and rewrites the cache.
setClearCache Allows for the user with sufficient access permissions to skip cache creation in this hit.
setClearCacheSession Allows for the user with sufficient access permissions to skip cache creation in this session.
shouldClearCache Returns true when the user with sufficient access permissions skips cache data reading in this session.

$cache = Bitrix\Main\Data\Cache::createInstance();
if ($cache->initCache($cacheTime, $cacheId, $cacheDir))
{
    $result = $cache->getVars();
}
elseif ($cache->startDataCache())
{
    $result = array();
    // ...
    if ($isInvalid)
    {
        $cache->abortDataCache();
    }
    // ...
    $cache->endDataCache($result);
} 
© «Bitrix24», 2001-2024
Up