1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
cacheengineapc.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Data;
4
5use Bitrix\Main\Data\LocalStorage\Storage;
6
8{
9 public function getConnectionName(): string
10 {
11 return '';
12 }
13
14 public static function getConnectionClass()
15 {
16 return CacheEngineApc::class;
17 }
18
19 protected function connect($config)
20 {
21 self::$isConnected = function_exists('apcu_fetch') && 'cli' !== \PHP_SAPI;
22 }
23
24 public function set($key, $ttl, $value)
25 {
26 return apcu_store($key, $value, $ttl);
27 }
28
29 public function get($key)
30 {
31 return apcu_fetch($key);
32 }
33
34 public function del($key)
35 {
36 apcu_delete($key);
37 }
38
39 public function setNotExists($key, $ttl, $value)
40 {
41 $ttl = (int) $ttl;
42 return apcu_add($key, $value, $ttl);
43 }
44
45 public function checkInSet($key, $value) : bool
46 {
47 $list = apcu_fetch($key);
48
49 if (!is_array($list))
50 {
51 $list = [];
52 }
53
54 if (array_key_exists($value, $list))
55 {
56 return true;
57 }
58
59 return false;
60 }
61
62 public function addToSet($key, $value)
63 {
64 $list = apcu_fetch($key);
65
66 if (!is_array($list))
67 {
68 $list = [];
69 }
70
71 if (!array_key_exists($value, $list))
72 {
73 $list[$value] = 1;
74 apcu_store($key, $list, 0);
75 }
76 }
77
78 public function getSet($key) : array
79 {
80 $list = apcu_fetch($key);
81 if (!is_array($list) || empty($list))
82 {
83 return [];
84 }
85
86 return array_keys($list);
87 }
88
89 public function deleteBySet($key, $prefix = '')
90 {
91 $list = apcu_fetch($key);
92 apcu_delete($key);
93
94 if (is_array($list) && !empty($list))
95 {
96 array_walk($list, function ($value, $key) {
97 apcu_delete($key);
98 });
99 unset($list);
100 }
101 }
102
103 public function delFromSet($key, $member)
104 {
105 $list = apcu_fetch($key);
106
107 if (is_array($list) && !empty($list))
108 {
109 $rewrite = false;
110 if (!is_array($member))
111 {
112 $member = [0 => $member];
113 }
114
115 foreach ($member as $keyID)
116 {
117 if (array_key_exists($keyID, $list))
118 {
119 $rewrite = true;
120 unset($list[$keyID]);
121 }
122 }
123
124 if ($rewrite)
125 {
126 if (empty($list))
127 {
128 apcu_delete($key);
129 }
130 else
131 {
132 apcu_store($key, $list, 0);
133 }
134 }
135 }
136 }
137}
deleteBySet($key, $prefix='')
Определения cacheengineapc.php:89
static getConnectionClass()
Определения cacheengineapc.php:14
setNotExists($key, $ttl, $value)
Определения cacheengineapc.php:39
delFromSet($key, $member)
Определения cacheengineapc.php:103
checkInSet($key, $value)
Определения cacheengineapc.php:45
addToSet($key, $value)
Определения cacheengineapc.php:62
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$config
Определения quickway.php:69
if(empty($signedUserToken)) $key
Определения quickway.php:257