1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
stack_cache.php
См. документацию.
1<?php
2
9
11{
13 var $cache = array();
16 var $eventHandlerAdded = false;
17
18 function SetLength($entity, $length)
19 {
20 if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE)
21 return;
22
23 if(isset($this->cache[$entity]) && is_object($this->cache[$entity]))
24 $this->cache[$entity]->SetLength($length);
25 else
26 $this->cacheLen[$entity] = $length;
27 }
28
29 function SetTTL($entity, $ttl)
30 {
31 if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE)
32 return;
33
34 if(isset($this->cache[$entity]) && is_object($this->cache[$entity]))
35 $this->cache[$entity]->SetTTL($ttl);
36 else
37 $this->cacheTTL[$entity] = $ttl;
38 }
39
40 function Init($entity, $length = 0, $ttl = 0)
41 {
42 if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE)
43 return;
44
45 if (!$this->eventHandlerAdded)
46 {
47 AddEventHandler("main", "OnEpilog", array("CStackCacheManager", "SaveAll"));
48 $this->eventHandlerAdded = true;
49 }
50
51 if($length <= 0 && isset($this->cacheLen[$entity]))
52 $length = $this->cacheLen[$entity];
53
54 if($ttl <= 0 && isset($this->cacheTTL[$entity]))
55 $ttl = $this->cacheTTL[$entity];
56
57 if (!array_key_exists($entity, $this->cache))
58 $this->cache[$entity] = new CStackCacheEntry($entity, $length, $ttl);
59 }
60
61 function Load($entity)
62 {
63 if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE)
64 return;
65
66 if (!array_key_exists($entity, $this->cache))
67 $this->Init($entity);
68
69 $this->cache[$entity]->Load();
70 }
71
72 //NO ONE SHOULD NEVER EVER USE INTEGER $id HERE
73 function Clear($entity, $id = false)
74 {
75 if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE)
76 return;
77
78 if (!array_key_exists($entity, $this->cache))
79 $this->Load($entity);
80
81 if ($id !== false)
82 $this->cache[$entity]->DeleteEntry($id);
83 else
84 $this->cache[$entity]->Clean();
85 }
86
87 // Clears all managed_cache
88 function CleanAll()
89 {
90 $this->cache = array();
91
92 $objCache = new CPHPCache;
93 $objCache->CleanDir(false, "stack_cache");
94 }
95
96 //NO ONE SHOULD NEVER EVER USE INTEGER $id HERE
97 function Exist($entity, $id)
98 {
99 if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE)
100 return false;
101
102 if (!array_key_exists($entity, $this->cache))
103 $this->Load($entity);
104
105 return array_key_exists($id, $this->cache[$entity]->values);
106 }
107
108 //NO ONE SHOULD NEVER EVER USE INTEGER $id HERE
109 function Get($entity, $id)
110 {
111 if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE)
112 return false;
113
114 if (!array_key_exists($entity, $this->cache))
115 $this->Load($entity);
116
117 return $this->cache[$entity]->Get($id);
118 }
119
120 //NO ONE SHOULD NEVER EVER USE INTEGER $id HERE
121 function Set($entity, $id, $value)
122 {
123 if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE)
124 return;
125
126 if (!array_key_exists($entity, $this->cache))
127 $this->Load($entity);
128
129 $this->cache[$entity]->Set($id, $value);
130 }
131
132 function Save($entity)
133 {
134 if(defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE)
135 return;
136
137 if(array_key_exists($entity, $this->cache))
138 $this->cache[$entity]->Save();
139 }
140
141 public static function SaveAll()
142 {
143 if(defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE)
144 return;
145
147 global $stackCacheManager;
148
149 foreach($stackCacheManager->cache as $value)
150 {
151 $value->Save();
152 }
153 }
154
155 function MakeIDFromArray($values)
156 {
157 $id = "id";
158
159 sort($values);
160
161 for ($i = 0, $c = count($values); $i < $c; $i++)
162 $id .= "_".$values[$i];
163
164 return $id;
165 }
166}
Определения stack_cache_entry.php:11
Clear($entity, $id=false)
Определения stack_cache.php:73
static SaveAll()
Определения stack_cache.php:141
Set($entity, $id, $value)
Определения stack_cache.php:121
Init($entity, $length=0, $ttl=0)
Определения stack_cache.php:40
$eventHandlerAdded
Определения stack_cache.php:16
Load($entity)
Определения stack_cache.php:61
Get($entity, $id)
Определения stack_cache.php:109
SetLength($entity, $length)
Определения stack_cache.php:18
SetTTL($entity, $ttl)
Определения stack_cache.php:29
Save($entity)
Определения stack_cache.php:132
$cache
Определения stack_cache.php:13
Exist($entity, $id)
Определения stack_cache.php:97
CleanAll()
Определения stack_cache.php:88
MakeIDFromArray($values)
Определения stack_cache.php:155
$cacheLen
Определения stack_cache.php:14
$cacheTTL
Определения stack_cache.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$entity
AddEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $CALLBACK, $SORT=100, $FULL_PATH=false)
Определения tools.php:5165
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936