1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
stack_cache_entry.php
См. документацию.
1
<?php
2
9
10
class
CStackCacheEntry
11
{
12
var
$entity
=
""
;
13
var
$id
=
""
;
14
var
$values
=
array
();
15
var
$len
= 10;
16
var
$ttl
= 3600;
17
var
$cleanGet
=
true
;
18
var
$cleanSet
=
true
;
19
20
function
__construct
(
$entity
, $length = 0,
$ttl
= 0)
21
{
22
$this->entity =
$entity
;
23
24
if
($length > 0)
25
$this->len = intval($length);
26
27
if
(
$ttl
> 0)
28
$this->ttl = intval(
$ttl
);
29
}
30
31
function
SetLength
($length)
32
{
33
if
($length > 0)
34
$this->len = intval($length);
35
36
while
(
count
($this->values) > $this->len)
37
{
38
$this->cleanSet =
false
;
39
array_shift($this->values);
40
}
41
}
42
43
function
SetTTL
(
$ttl
)
44
{
45
if
(
$ttl
> 0)
46
$this->ttl = intval(
$ttl
);
47
}
48
49
function
Load
()
50
{
51
global
$DB
;
52
$objCache = \Bitrix\Main\Data\Cache::createInstance();
53
if
($objCache->InitCache($this->ttl, $this->entity,
$DB
->type.
"/"
.$this->entity,
"stack_cache"
))
54
{
55
$this->values = $objCache->GetVars();
56
$this->cleanGet =
true
;
57
$this->cleanSet =
true
;
58
}
59
}
60
61
function
DeleteEntry
(
$id
)
62
{
63
if
(array_key_exists(
$id
, $this->values))
64
{
65
unset($this->values[
$id
]);
66
$this->cleanSet =
false
;
67
}
68
}
69
70
function
Clean
()
71
{
72
global
$DB
;
73
74
$objCache = \Bitrix\Main\Data\Cache::createInstance();
75
$objCache->Clean($this->entity,
$DB
->type.
"/"
.$this->entity,
"stack_cache"
);
76
77
$this->values =
array
();
78
$this->cleanGet =
true
;
79
$this->cleanSet =
true
;
80
}
81
82
function
Get
(
$id
)
83
{
84
if
(array_key_exists(
$id
, $this->values))
85
{
86
$result
= $this->values[
$id
];
87
//Move accessed value to the top of list only when it is not at the top
88
end($this->values);
89
if
(key($this->values) !==
$id
)
90
{
91
$this->cleanGet =
false
;
92
unset($this->values[
$id
]);
93
$this->values = $this->values +
array
(
$id
=>
$result
);
94
}
95
96
return
$result
;
97
}
98
else
99
{
100
return
false
;
101
}
102
}
103
104
function
Set
(
$id
, $value)
105
{
106
if
(array_key_exists(
$id
, $this->values))
107
{
108
unset($this->values[
$id
]);
109
$this->values = $this->values +
array
(
$id
=> $value);
110
}
111
else
112
{
113
$this->values = $this->values +
array
(
$id
=> $value);
114
while
(
count
($this->values) > $this->len)
115
array_shift($this->values);
116
}
117
118
$this->cleanSet =
false
;
119
}
120
121
function
Save
()
122
{
123
if
(defined(
"BITRIX_SKIP_STACK_CACHE"
) && BITRIX_SKIP_STACK_CACHE)
124
return
;
125
126
global
$DB
;
127
128
if
(
129
!$this->cleanSet
130
|| (
131
!$this->cleanGet
132
&& (
count
($this->values) >= $this->len)
133
)
134
)
135
{
136
$objCache = \Bitrix\Main\Data\Cache::createInstance();
137
138
//Force cache rewrite
139
$objCache->forceRewriting(
true
);
140
141
if
($objCache->startDataCache($this->ttl, $this->entity,
$DB
->type.
"/"
.$this->entity, $this->values,
"stack_cache"
))
142
{
143
$objCache->endDataCache();
144
}
145
146
$this->cleanGet =
true
;
147
$this->cleanSet =
true
;
148
}
149
}
150
}
CStackCacheEntry
Определения
stack_cache_entry.php:11
CStackCacheEntry\SetTTL
SetTTL($ttl)
Определения
stack_cache_entry.php:43
CStackCacheEntry\__construct
__construct($entity, $length=0, $ttl=0)
Определения
stack_cache_entry.php:20
CStackCacheEntry\Clean
Clean()
Определения
stack_cache_entry.php:70
CStackCacheEntry\$cleanGet
$cleanGet
Определения
stack_cache_entry.php:17
CStackCacheEntry\$ttl
$ttl
Определения
stack_cache_entry.php:16
CStackCacheEntry\SetLength
SetLength($length)
Определения
stack_cache_entry.php:31
CStackCacheEntry\$entity
$entity
Определения
stack_cache_entry.php:12
CStackCacheEntry\Set
Set($id, $value)
Определения
stack_cache_entry.php:104
CStackCacheEntry\DeleteEntry
DeleteEntry($id)
Определения
stack_cache_entry.php:61
CStackCacheEntry\$len
$len
Определения
stack_cache_entry.php:15
CStackCacheEntry\$cleanSet
$cleanSet
Определения
stack_cache_entry.php:18
CStackCacheEntry\Get
Get($id)
Определения
stack_cache_entry.php:82
CStackCacheEntry\Load
Load()
Определения
stack_cache_entry.php:49
CStackCacheEntry\$id
$id
Определения
stack_cache_entry.php:13
CStackCacheEntry\Save
Save()
Определения
stack_cache_entry.php:121
CStackCacheEntry\$values
$values
Определения
stack_cache_entry.php:14
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$DB
global $DB
Определения
cron_frame.php:29
count
</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
bitrix
modules
main
classes
general
stack_cache_entry.php
Создано системой
1.14.0