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");
26 * ACM for eAccelerator
28 * @todo Missing locks from destroy() talk with David
30 class acm extends acm_memory
32 var $extension = 'eaccelerator';
33 var $function = 'eaccelerator_get';
35 var $serialize_header = '#phpbb-serialized#';
44 foreach (eaccelerator_list_keys() as $var)
46 // @todo Check why the substr()
47 // @todo Only unset vars matching $this->key_prefix
48 eaccelerator_rm(substr($var['name'], 1));
55 * Perform cache garbage collection
63 set_config('cache_last_gc', time(), true);
67 * Fetch an item from the cache
70 * @param string $var Cache key
71 * @return mixed Cached data
75 $result = eaccelerator_get($this->key_prefix . $var);
82 // Handle serialized objects
83 if (is_string($result) && strpos($result, $this->serialize_header . 'O:') === 0)
85 $result = unserialize(substr($result, strlen($this->serialize_header)));
92 * Store data in the cache
95 * @param string $var Cache key
96 * @param mixed $data Data to store
97 * @param int $ttl Time-to-live of cached data
98 * @return bool True if the operation succeeded
100 function _write($var, $data, $ttl = 2592000)
102 // Serialize objects and make them easy to detect
103 $data = (is_object($data)) ? $this->serialize_header . serialize($data) : $data;
105 return eaccelerator_put($this->key_prefix . $var, $data, $ttl);
109 * Remove an item from the cache
112 * @param string $var Cache key
113 * @return bool True if the operation succeeded
115 function _delete($var)
117 return eaccelerator_rm($this->key_prefix . $var);