ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilApc.php
Go to the documentation of this file.
1 <?php
2 
3 require_once('./Services/GlobalCache/classes/class.ilGlobalCacheService.php');
4 require_once('./Services/Environment/classes/class.ilRuntime.php');
5 
15 {
16  const MIN_MEMORY = 16;
17  const CACHE_ID = 'user';
18 
19 
25  public function exists($key)
26  {
27  if (function_exists('apcu_exists')) {
28  return apcu_exists($this->returnKey($key));
29  } else {
30  return apcu_fetch($this->returnKey($key));
31  }
32  }
33 
34 
42  public function set($key, $serialized_value, $ttl = 0)
43  {
44  return apcu_store($this->returnKey($key), $serialized_value, $ttl);
45  }
46 
47 
53  public function get($key)
54  {
55  return apcu_fetch($this->returnKey($key));
56  }
57 
58 
64  public function delete($key)
65  {
66  return apcu_delete($this->returnKey($key));
67  }
68 
69 
73  public function flush()
74  {
75  return apcu_clear_cache();
76  }
77 
78 
84  public function serialize($value)
85  {
86  return ($value);
87  }
88 
89 
95  public function unserialize($serialized_value)
96  {
97  return ($serialized_value);
98  }
99 
100 
104  public function getInfo()
105  {
106  $return = array();
107 
108  $cache_info = apc_cache_info();
109 
110  unset($cache_info['cache_list']);
111  unset($cache_info['slot_distribution']);
112 
113  $return['__cache_info'] = array(
114  'apc.enabled' => ini_get('apc.enabled'),
115  'apc.shm_size' => ini_get('apc.shm_size'),
116  'apc.shm_segments' => ini_get('apc.shm_segments'),
117  'apc.gc_ttl' => ini_get('apc.gc_ttl'),
118  'apc.user_ttl' => ini_get('apc.ttl'),
119  'info' => $cache_info,
120  );
121 
122  $cache_info = apc_cache_info();
123  foreach ($cache_info['cache_list'] as $dat) {
124  $key = $dat['key'];
125 
126  if (preg_match('/' . $this->getServiceId() . '_' . $this->getComponent() . '/', $key)) {
127  $return[$key] = apc_fetch($key);
128  }
129  }
130 
131  return $return;
132  }
133 
134 
135  protected function getActive()
136  {
137  return function_exists('apcu_store');
138  }
139 
140 
144  protected function getInstallable()
145  {
146  return function_exists('apcu_store');
147  }
148 
149 
153  protected function getMemoryLimit()
154  {
155  if (ilRuntime::getInstance()->isHHVM()) {
156  return $this->getMinMemory() . 'M';
157  }
158 
159  return ini_get('apc.shm_size');
160  }
161 
162 
166  protected function getMinMemory()
167  {
168  return self::MIN_MEMORY;
169  }
170 
171 
175  public function isValid($key)
176  {
177  return true;
178  }
179 }
exists($key)
Definition: class.ilApc.php:25
static getInstance()
const CACHE_ID
Definition: class.ilApc.php:17
getMemoryLimit()
getActive()
Class ilGlobalCacheService.
unserialize($serialized_value)
Definition: class.ilApc.php:95
isValid($key)
serialize($value)
Definition: class.ilApc.php:84
Create styles array
The data for the language used.
Class ilApc.
Definition: class.ilApc.php:14
const MIN_MEMORY
Definition: class.ilApc.php:16
getInstallable()
getMinMemory()
$key
Definition: croninfo.php:18