indvdum@0: 0 indvdum@0: * - xcache.admin.enable_auth = off (or xcache.admin.user and xcache.admin.password set) indvdum@0: * indvdum@0: */ indvdum@0: class acm extends acm_memory indvdum@0: { indvdum@0: var $extension = 'XCache'; indvdum@0: indvdum@0: function acm() indvdum@0: { indvdum@0: parent::acm_memory(); indvdum@0: indvdum@0: if (!function_exists('ini_get') || (int) ini_get('xcache.var_size') <= 0) indvdum@0: { indvdum@0: trigger_error('Increase xcache.var_size setting above 0 or enable ini_get() to use this ACM module.', E_USER_ERROR); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Purge cache data indvdum@0: * indvdum@0: * @return void indvdum@0: */ indvdum@0: function purge() indvdum@0: { indvdum@0: // Run before for XCache, if admin functions are disabled it will terminate execution indvdum@0: parent::purge(); indvdum@0: indvdum@0: // If the admin authentication is enabled but not set up, this will cause a nasty error. indvdum@0: // Not much we can do about it though. indvdum@0: $n = xcache_count(XC_TYPE_VAR); indvdum@0: indvdum@0: for ($i = 0; $i < $n; $i++) indvdum@0: { indvdum@0: xcache_clear_cache(XC_TYPE_VAR, $i); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Fetch an item from the cache indvdum@0: * indvdum@0: * @access protected indvdum@0: * @param string $var Cache key indvdum@0: * @return mixed Cached data indvdum@0: */ indvdum@0: function _read($var) indvdum@0: { indvdum@0: $result = xcache_get($this->key_prefix . $var); indvdum@0: indvdum@0: return ($result !== null) ? $result : false; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Store data in the cache indvdum@0: * indvdum@0: * @access protected indvdum@0: * @param string $var Cache key indvdum@0: * @param mixed $data Data to store indvdum@0: * @param int $ttl Time-to-live of cached data indvdum@0: * @return bool True if the operation succeeded indvdum@0: */ indvdum@0: function _write($var, $data, $ttl = 2592000) indvdum@0: { indvdum@0: return xcache_set($this->key_prefix . $var, $data, $ttl); indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Remove an item from the cache indvdum@0: * indvdum@0: * @access protected indvdum@0: * @param string $var Cache key indvdum@0: * @return bool True if the operation succeeded indvdum@0: */ indvdum@0: function _delete($var) indvdum@0: { indvdum@0: return xcache_unset($this->key_prefix . $var); indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Check if a cache var exists indvdum@0: * indvdum@0: * @access protected indvdum@0: * @param string $var Cache key indvdum@0: * @return bool True if it exists, otherwise false indvdum@0: */ indvdum@0: function _isset($var) indvdum@0: { indvdum@0: return xcache_isset($this->key_prefix . $var); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: ?>