<optiontype>radiobuttons</optiontype>\r
<defaultvalue><![CDATA[disk]]></defaultvalue>\r
<selectoptions><![CDATA[disk:wcf.acp.option.cache_source_type.disk\r
-memcache:wcf.acp.option.cache_source_type.memcache]]></selectoptions>\r
+memcache:wcf.acp.option.cache_source_type.memcache\r
+apc:wcf.acp.option.cache_source_type.apc]]></selectoptions>\r
<enableoptions><![CDATA[disk:!cache_source_memcache_host,!cache_source_memcache_use_pconnect,!enable_session_data_cache\r
-memcache:cache_source_memcache_host,cache_source_memcache_use_pconnect,enable_session_data_cache]]></enableoptions>\r
+memcache:cache_source_memcache_host,cache_source_memcache_use_pconnect,enable_session_data_cache\r
+apc:!cache_source_memcache_host,!cache_source_memcache_use_pconnect,!enable_session_data_cache]]></enableoptions>\r
</option>\r
\r
<option name="enable_session_data_cache">\r
--- /dev/null
+<?php
+namespace wcf\system\cache\source;
+use wcf\system\exception\SystemException;
+use wcf\util\FileUtil;
+
+/**
+ * ApcCacheSource is an implementation of CacheSource that uses APC to store cached variables.
+ *
+ * @author Markus Bartz
+ * @copyright 2011 Markus Bartz
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.cache.source
+ * @category Community Framework
+ */
+class ApcCacheSource implements CacheSource {
+ /**
+ * Creates a new ApcCacheSource object.
+ */
+ public function __construct() {
+ if (!function_exists('apc_exists')) {
+ throw new SystemException('APC support is not enabled.');
+ }
+ }
+
+ /**
+ * @see CacheSource::get()
+ */
+ public function get($cacheResource) {
+ if (!apc_exists($cacheResource['file'])) {
+ return null;
+ }
+
+ return apc_fetch($cacheResource['file']);
+ }
+
+ /**
+ * @see CacheSource::set()
+ */
+ public function set($cacheResource, $value) {
+ apc_store($cacheResource['file'], $value, $cacheResource['maxLifetime']);
+ }
+
+ /**
+ * @see CacheSource::delete()
+ */
+ public function delete($cacheResource, $ignoreLifetime = false) {
+ if ($ignoreLifetime || ($cacheResource['minLifetime'] == 0 || $this->checkMinLifetime($cacheResource))) {
+ apc_delete($cacheResource['file']);
+ }
+ }
+
+ /**
+ * Checks if the minimum lifetime is expired.
+ *
+ * @param array $cacheResource
+ */
+ public function checkMinLifetime($cacheResource) {
+ $apcinfo = apc_cache_info('user');
+ $cacheList = $apcinfo['cache_list'];
+
+ foreach ($cacheList as $cache) {
+ if ($cache['info'] == $cacheResource['file']) {
+ return ((TIME_NOW - $cache['mtime']) >= $cacheResource['minLifetime']);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * @see CacheSource::clear()
+ */
+ public function clear($directory, $filepattern, $forceDelete = false) {
+ $pattern = preg_quote(FileUtil::addTrailingSlash($directory), '%').str_replace('*', '.*', str_replace('.', '\.', $filepattern));
+
+ $apcinfo = apc_cache_info('user');
+ $cacheList = $apcinfo['cache_list'];
+ foreach ($cacheList as $cache) {
+ if (preg_match('%^'.$pattern.'$%i', $cache['info'])) {
+ apc_delete($cache['info']);
+ }
+ }
+ }
+
+ /**
+ * @see CacheSource::close()
+ */
+ public function close() {
+ // does nothing
+ }
+
+ /**
+ * @see CacheSource::flush()
+ */
+ public function flush() {
+ apc_clear_cache('user');
+ }
+}
+?>
<item name="wcf.acp.option.cache_source_memcache_use_pconnect"><![CDATA[Persistente Verbindungen aktivieren]]></item>\r
<item name="wcf.acp.option.cache_source_memcache_use_pconnect.description"><![CDATA[Sollen beim Verbinden mit dem Memcache-Server persistente Verbindungen genutzt werden?]]></item>\r
<item name="wcf.acp.option.cache_source_type"><![CDATA[Cache-Methode]]></item>\r
+ <item name="wcf.acp.option.cache_source_type.apc"><![CDATA[Alternative PHP Cache]]></item>\r
<item name="wcf.acp.option.cache_source_type.description"><![CDATA[Bitte wähle die gewünschte Cache-Methode aus! Beachte, dass einige Methoden spezielle Anforderungen an das Server-System stellen und nicht auf jedem Server zur Verfügung stehen.]]></item>\r
<item name="wcf.acp.option.cache_source_type.disk"><![CDATA[Dateisystem (Standard)]]></item>\r
<item name="wcf.acp.option.cache_source_type.memcache"><![CDATA[Memcache (Experimentell)]]></item>\r
<item name="wcf.acp.option.cache_source_memcache_use_pconnect"><![CDATA[Persistente Verbindungen aktivieren]]></item>\r
<item name="wcf.acp.option.cache_source_memcache_use_pconnect.description"><![CDATA[Sollen beim Verbinden mit dem Memcache-Server persistente Verbindungen genutzt werden?]]></item>\r
<item name="wcf.acp.option.cache_source_type"><![CDATA[Cache-Methode]]></item>\r
+ <item name="wcf.acp.option.cache_source_type.apc"><![CDATA[Alternative PHP Cache]]></item>\r
<item name="wcf.acp.option.cache_source_type.description"><![CDATA[Bitte wählen Sie die gewünschte Cache-Methode aus! Beachten Sie, dass einige Methoden spezielle Anforderungen an das Server-System stellen und nicht auf jedem Server zur Verfügung stehen.]]></item>\r
<item name="wcf.acp.option.cache_source_type.disk"><![CDATA[Dateisystem (Standard)]]></item>\r
<item name="wcf.acp.option.cache_source_type.memcache"><![CDATA[Memcache (Experimentell)]]></item>\r
<item name="wcf.acp.option.cache_source_memcache_use_pconnect"><![CDATA[Use persistent connections]]></item>\r
<item name="wcf.acp.option.cache_source_memcache_use_pconnect.description"><![CDATA[By enabling this option a persistent connection to the memcache server will be used.]]></item>\r
<item name="wcf.acp.option.cache_source_type"><![CDATA[Cache type]]></item>\r
+ <item name="wcf.acp.option.cache_source_type.apc"><![CDATA[Alternative PHP Cache]]></item>\r
<item name="wcf.acp.option.cache_source_type.description"><![CDATA[Please select the type of cache you want to use. Some of the types have special requirements to the server system and cannot be used in your environment.]]></item>\r
<item name="wcf.acp.option.cache_source_type.disk"><![CDATA[File system (default)]]></item>\r
<item name="wcf.acp.option.cache_source_type.memcache"><![CDATA[Memcache (experimental)]]></item>\r