10 defined(
'JPATH_PLATFORM') or die;
33 public function get($id, $group, $checkTime =
true)
35 $cache_id = $this->_getCacheId($id, $group);
36 return apc_fetch($cache_id);
46 public function getAll()
50 $allinfo = apc_cache_info(
'user');
51 $keys = $allinfo[
'cache_list'];
52 $secret = $this->_hash;
56 foreach ($keys as $key)
60 $namearr = explode(
'-', $name);
62 if ($namearr !==
false && $namearr[0] == $secret && $namearr[1] ==
'cache')
66 if (!isset($data[$group]))
72 $item = $data[$group];
75 $item->updateSize($key[
'mem_size'] / 1024);
77 $data[$group] = $item;
95 public function store($id, $group, $data)
97 $cache_id = $this->_getCacheId($id, $group);
98 return apc_store($cache_id, $data, $this->_lifetime);
111 public function remove($id, $group)
113 $cache_id = $this->_getCacheId($id, $group);
114 return apc_delete($cache_id);
130 public function clean($group, $mode = null)
132 $allinfo = apc_cache_info(
'user');
133 $keys = $allinfo[
'cache_list'];
134 $secret = $this->_hash;
136 foreach ($keys as $key)
139 if (strpos($key[
'info'], $secret .
'-cache-' . $group .
'-') === 0 xor $mode !=
'group')
141 apc_delete($key[
'info']);
156 $allinfo = apc_cache_info(
'user');
157 $keys = $allinfo[
'cache_list'];
158 $secret = $this->_hash;
160 foreach ($keys as $key)
162 if (strpos($key[
'info'], $secret .
'-cache-'))
164 apc_fetch($key[
'info']);
176 public static function isSupported()
178 return extension_loaded(
'apc');
192 public function lock($id, $group, $locktime)
194 $returning =
new stdClass;
195 $returning->locklooped =
false;
197 $looptime = $locktime * 10;
199 $cache_id = $this->_getCacheId($id, $group) .
'_lock';
201 $data_lock = apc_add($cache_id, 1, $locktime);
203 if ($data_lock ===
false)
210 while ($data_lock ===
false)
213 if ($lock_counter > $looptime)
215 $returning->locked =
false;
216 $returning->locklooped =
true;
221 $data_lock = apc_add($cache_id, 1, $locktime);
226 $returning->locked = $data_lock;
241 public function unlock($id, $group = null)
243 $cache_id = $this->_getCacheId($id, $group) .
'_lock';
245 $unlock = apc_delete($cache_id);