memcache = new Memcache; $this->memcache->connect(PHPBB_ACM_MEMCACHE_HOST, PHPBB_ACM_MEMCACHE_PORT); $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; } /** * Unload the cache resources * * @return void */ function unload() { parent::unload(); $this->memcache->close(); } /** * Purge cache data * * @return void */ function purge() { $this->memcache->flush(); parent::purge(); } /** * Fetch an item from the cache * * @access protected * @param string $var Cache key * @return mixed Cached data */ function _read($var) { return $this->memcache->get($this->key_prefix . $var); } /** * Store data in the cache * * @access protected * @param string $var Cache key * @param mixed $data Data to store * @param int $ttl Time-to-live of cached data * @return bool True if the operation succeeded */ function _write($var, $data, $ttl = 2592000) { if (!$this->memcache->replace($this->key_prefix . $var, $data, $this->flags, $ttl)) { return $this->memcache->set($this->key_prefix . $var, $data, $this->flags, $ttl); } return true; } /** * Remove an item from the cache * * @access protected * @param string $var Cache key * @return bool True if the operation succeeded */ function _delete($var) { return $this->memcache->delete($this->key_prefix . $var); } } ?>