ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilApc.php
Go to the documentation of this file.
1<?php
2
3require_once('./Services/GlobalCache/classes/class.ilGlobalCacheService.php');
4require_once('./Services/Environment/classes/class.ilRuntime.php');
5
15
16 const MIN_MEMORY = 128;
17 const CACHE_ID = 'user';
18
19
25 public function exists($key) {
26 if (function_exists('apc_exists')) {
27 return apc_exists($this->returnKey($key));
28 } else {
29 return apc_fetch($this->returnKey($key)) !== NULL;
30 }
31 }
32
33
41 public function set($key, $serialized_value, $ttl = 0) {
42 return apc_store($this->returnKey($key), $serialized_value, $ttl);
43 }
44
45
51 public function get($key) {
52 return apc_fetch($this->returnKey($key));
53 }
54
55
61 public function delete($key) {
62 return apc_delete($this->returnKey($key));
63 }
64
65
69 public function flush() {
70 return apc_clear_cache(self::CACHE_ID);
71 }
72
73
79 public function serialize($value) {
80 return ($value);
81 }
82
83
89 public function unserialize($serialized_value) {
90 return ($serialized_value);
91 }
92
93
97 public function getInfo() {
98 $return = array();
99
100 $cache_info = apc_cache_info();
101
102 unset($cache_info['cache_list']);
103 unset($cache_info['slot_distribution']);
104
105 $return['__cache_info'] = array(
106 'apc.enabled' => ini_get('apc.enabled'),
107 'apc.shm_size' => ini_get('apc.shm_size'),
108 'apc.shm_segments' => ini_get('apc.shm_segments'),
109 'apc.gc_ttl' => ini_get('apc.gc_ttl'),
110 'apc.user_ttl' => ini_get('apc.ttl'),
111 'info' => $cache_info
112 );
113
114 $cache_info = apc_cache_info();
115 foreach ($cache_info['cache_list'] as $dat) {
116 $key = $dat['key'];
117
118 if (preg_match('/' . $this->getServiceId() . '_' . $this->getComponent() . '/', $key)) {
119 $return[$key] = apc_fetch($key);
120 }
121 }
122
123 return $return;
124 }
125
126
127 protected function getActive() {
128 return function_exists('apc_store');
129 }
130
131
135 protected function getInstallable() {
136 return function_exists('apc_store');
137 }
138
139
143 protected function getMemoryLimit() {
144 if (ilRuntime::getInstance()->isHHVM()) {
145 return $this->getMinMemory() . 'M';
146 }
147
148 return ini_get('apc.shm_size');
149 }
150
151
155 protected function getMinMemory() {
156 return self::MIN_MEMORY;
157 }
158}
159
160?>
Class ilApc.
Definition: class.ilApc.php:14
exists($key)
Definition: class.ilApc.php:25
getActive()
getMemoryLimit()
const MIN_MEMORY
Definition: class.ilApc.php:16
unserialize($serialized_value)
Definition: class.ilApc.php:89
const CACHE_ID
Definition: class.ilApc.php:17
getInstallable()
serialize($value)
Definition: class.ilApc.php:79
getMinMemory()
getInfo()
Definition: class.ilApc.php:97
Class ilGlobalCacheService.
static getInstance()