indvdum@0: memcache = new Memcache; indvdum@0: foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u) indvdum@0: { indvdum@0: $parts = explode('/', $u); indvdum@0: $this->memcache->addServer(trim($parts[0]), trim($parts[1])); indvdum@0: } indvdum@0: $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Unload the cache resources indvdum@0: * indvdum@0: * @return void indvdum@0: */ indvdum@0: function unload() indvdum@0: { indvdum@0: parent::unload(); indvdum@0: indvdum@0: $this->memcache->close(); 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: $this->memcache->flush(); indvdum@0: indvdum@0: parent::purge(); 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: return $this->memcache->get($this->key_prefix . $var); 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: if (!$this->memcache->replace($this->key_prefix . $var, $data, $this->flags, $ttl)) indvdum@0: { indvdum@0: return $this->memcache->set($this->key_prefix . $var, $data, $this->flags, $ttl); indvdum@0: } indvdum@0: return true; 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 $this->memcache->delete($this->key_prefix . $var); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: ?>