Source for file xcache.php
Documentation is available at xcache.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* XCache cache storage handler
* @package Joomla.Platform
* @link http://xcache.lighttpd.net/
* Get cached data by id and group
* @param string $id The cache data id
* @param string $group The cache data group
* @param boolean $checkTime True to verify cache time expiration threshold
* @return mixed Boolean false on failure or a cached data string
public function get($id, $group, $checkTime =
true)
$cache_content =
xcache_get($cache_id);
if ($cache_content ===
null)
* This requires the php.ini setting xcache.admin.enable_auth = Off.
$allinfo =
xcache_list(XC_TYPE_VAR, 0);
$keys =
$allinfo['cache_list'];
$namearr =
explode('-', $key['name']);
if ($namearr !==
false &&
$namearr[0] ==
$secret &&
$namearr[1] ==
'cache')
if (!isset
($data[$group]))
$item->updateSize($key['size'] /
1024);
* Store the data by id and group
* @param string $id The cache data id
* @param string $group The cache data group
* @param string $data The data to store in cache
* @return boolean True on success, false otherwise
public function store($id, $group, $data)
$store =
xcache_set($cache_id, $data, $this->_lifetime);
* Remove a cached data entry by id and group
* @param string $id The cache data id
* @param string $group The cache data group
* @return boolean True on success, false otherwise
public function remove($id, $group)
if (!xcache_isset($cache_id))
return xcache_unset($cache_id);
* Clean cache for a group given a mode.
* This requires the php.ini setting xcache.admin.enable_auth = Off.
* @param string $group The cache data group
* @param string $mode The mode for cleaning cache [group|notgroup]
* group mode : cleans all cache in the group
* notgroup mode : cleans all cache not in the group
* @return boolean True on success, false otherwise
public function clean($group, $mode =
null)
$allinfo =
xcache_list(XC_TYPE_VAR, 0);
$keys =
$allinfo['cache_list'];
if (strpos($key['name'], $secret .
'-cache-' .
$group .
'-') ===
0 xor $mode !=
'group')
xcache_unset($key['name']);
* Garbage collect expired cache data
* This is a dummy, since xcache has built in garbage collector, turn it
* on in php.ini by changing default xcache.gc_interval setting from
* @return boolean True on success, false otherwise.
$cachecount = xcache_count(XC_TYPE_VAR);
for ($i = 0; $i < $cachecount; $i ++) {
$allinfo = xcache_list(XC_TYPE_VAR, $i);
$keys = $allinfo ['cache_list'];
if (strstr($key['name'], $this->_hash)) {
if (($key['ctime'] + $this->_lifetime ) < $this->_now) xcache_unset($key['name']);
* Test to see if the cache storage is available.
* @return boolean True on success, false otherwise.
Documentation generated on Tue, 19 Nov 2013 15:18:36 +0100 by phpDocumentor 1.4.3