6 * @copyright (c) 2005, 2009 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 if (!defined('IN_PHPBB'))
19 // Include the abstract base
20 if (!class_exists('acm_memory'))
22 require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx");
29 * To use this module you need ini_get() enabled and the following INI settings configured as follows:
30 * - xcache.var_size > 0
31 * - xcache.admin.enable_auth = off (or xcache.admin.user and xcache.admin.password set)
34 class acm extends acm_memory
36 var $extension = 'XCache';
42 if (!function_exists('ini_get') || (int) ini_get('xcache.var_size') <= 0)
44 trigger_error('Increase xcache.var_size setting above 0 or enable ini_get() to use this ACM module.', E_USER_ERROR);
55 // Run before for XCache, if admin functions are disabled it will terminate execution
58 // If the admin authentication is enabled but not set up, this will cause a nasty error.
59 // Not much we can do about it though.
60 $n = xcache_count(XC_TYPE_VAR);
62 for ($i = 0; $i < $n; $i++)
64 xcache_clear_cache(XC_TYPE_VAR, $i);
69 * Fetch an item from the cache
72 * @param string $var Cache key
73 * @return mixed Cached data
77 $result = xcache_get($this->key_prefix . $var);
79 return ($result !== null) ? $result : false;
83 * Store data in the cache
86 * @param string $var Cache key
87 * @param mixed $data Data to store
88 * @param int $ttl Time-to-live of cached data
89 * @return bool True if the operation succeeded
91 function _write($var, $data, $ttl = 2592000)
93 return xcache_set($this->key_prefix . $var, $data, $ttl);
97 * Remove an item from the cache
100 * @param string $var Cache key
101 * @return bool True if the operation succeeded
103 function _delete($var)
105 return xcache_unset($this->key_prefix . $var);
109 * Check if a cache var exists
112 * @param string $var Cache key
113 * @return bool True if it exists, otherwise false
115 function _isset($var)
117 return xcache_isset($this->key_prefix . $var);