• Модуль: learning
  • Путь к файлу: ~/bitrix/modules/learning/classes/general/clearnlesson.php
  • Класс: CLearnLesson
  • Вызов: CLearnLesson::GetCourseToLessonMap
static function GetCourseToLessonMap($bRefreshCache = false)
{
	static $arMap = array();
	$bCacheHit = false;
	static $ttl = 1800;	// seconds
	static $cacheId = 'fixed_cache_id';
	static $cachePath = '/learning/coursetolessonmap/';

	$oCache = new CPHPCache();

	// Try to load from cache only if cache isn't dirty
	if ( ! $bRefreshCache )
	{
		if ($oCache->InitCache($ttl, $cacheId, $cachePath))
		{
			$arCached = $oCache->GetVars();
			if (isset($arCached['arMap']) && is_array($arCached['arMap']))
			{
				$arMap = $arCached['arMap'];
				$bCacheHit = true;
			}
		}
	}

	// Reload map from DB on cache miss or when cache is dirty
	if (( ! $bCacheHit ) || $bRefreshCache)
	{
		$oCache->CleanDir($cachePath);

		$arMap = self::GetCourseToLessonMap_LoadFromDB();
		$oCache->InitCache($ttl, $cacheId, $cachePath);
		$oCache->StartDataCache($ttl, $cacheId, $cachePath);
		$oCache->EndDataCache(array('arMap' => $arMap));
	}

	return ($arMap);
}