1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
clearncacheoflessontreecomponent.php
См. документацию.
1<?php
2
4{
5 const OPTION_NAME = '~CacheOfLessonTreeComponentIsDirty';
6 const OPTION_TS = '~CacheOfLessonTreeComponentTS'; // timestamp of last ditry cache
7 const CACHE_PATH = '/learning/LessonTreeComponent/';
8 const TTL = 3600;
9
10 public static function IsDirty()
11 {
12 $isCacheDirty = COption::GetOptionInt(
13 'learning',
14 self::OPTION_NAME,
15 1);
16
17 return ( (boolean) $isCacheDirty );
18 }
19
20
21 public static function MarkAsDirty()
22 {
23 COption::SetOptionString(
24 'learning',
25 self::OPTION_NAME,
26 1
27 );
28
29 COption::SetOptionString(
30 'learning',
31 self::OPTION_TS,
32 time()
33 );
34 }
35
36
37 public static function MarkAsClean()
38 {
39 COption::SetOptionString(
40 'learning',
41 self::OPTION_NAME,
42 0
43 );
44 }
45
46
47 public static function Purge()
48 {
49 $oCache = new CPHPCache();
50 $oCache->CleanDir(self::CACHE_PATH);
51 }
52
53
54 public static function GetData($courseId)
55 {
56 $arContents = array();
57 $cacheId = 'course_id_' . (string) ((int) $courseId);
58 $oCache = new CPHPCache();
59
60 if (
61 $oCache->InitCache(self::TTL, $cacheId, self::CACHE_PATH)
62 && ( ! self::IsDirty() )
63 )
64 {
65 $arCached = $oCache->GetVars();
66 if (isset($arCached['arContents']) && is_array($arCached['arContents']))
67 $arContents = $arCached['arContents'];
68 }
69 else
70 {
72
73 $arContents = self::GetDataWoCache($courseId);
74 $oCache->StartDataCache(self::TTL, $cacheId, self::CACHE_PATH);
75 $oCache->EndDataCache(array('arContents' => $arContents));
76
78 }
79
80 return ($arContents);
81 }
82
83
84 protected static function GetDataWoCache($courseId)
85 {
86 $rsContent = CCourse::GetCourseContent(
87 $courseId,
88 array(),
89 array('LESSON_ID', 'NAME')
90 );
91
92 $arContents = array();
93 while ($arContent = $rsContent->GetNext())
94 $arContents[] = $arContent;
95
96 return ($arContents);
97 }
98}
static GetCourseContent( $COURSE_ID, $arAddSelectFileds=array("DETAIL_TEXT", "DETAIL_TEXT_TYPE", "DETAIL_PICTURE"), $arSelectFields=array())
Определения course.php:402
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804