<selectoptions><![CDATA[disk:wcf.acp.option.cache_source_type.disk
memcached:wcf.acp.option.cache_source_type.memcached
no:wcf.acp.option.cache_source_type.no]]></selectoptions>
- <!-- apc:wcf.acp.option.cache_source_type.apc -->
<enableoptions><![CDATA[disk:!cache_source_memcached_host
memcached:cache_source_memcached_host
no:!cache_source_memcached_host]]></enableoptions>
- <!-- apc:!cache_source_memcached_host -->
</option>
<option name="cache_source_memcached_host">
$this->cacheData['version'] = WCF_VERSION;
break;
- case 'wcf\system\cache\source\ApcCacheSource':
- // set version
- $this->cacheData['version'] = phpversion('apc');
-
- $apcinfo = apc_cache_info('user');
- $cacheList = $apcinfo['cache_list'];
- usort($cacheList, function ($a, $b) {
- return $a['info'] > $b['info'];
- });
-
- $prefix = new Regex('^WCF_'.substr(sha1(WCF_DIR), 0, 10) . '_');
- foreach ($cacheList as $cache) {
- if (!$prefix->match($cache['info'])) continue;
-
- // get additional cache information
- $this->caches['data']['apc'][] = array(
- 'filename' => $prefix->replace($cache['info'], ''),
- 'filesize' => $cache['mem_size'],
- 'mtime' => $cache['mtime']
- );
-
- $this->cacheData['files']++;
- $this->cacheData['size'] += $cache['mem_size'];
- }
- break;
-
case 'wcf\system\cache\source\NoCacheSource':
$this->cacheData['version'] = WCF_VERSION;
break;
+++ /dev/null
-<?php
-namespace wcf\system\cache\source;
-use wcf\system\exception\SystemException;
-use wcf\system\Regex;
-use wcf\util\StringUtil;
-
-/**
- * ApcCacheSource is an implementation of CacheSource that uses APC to store cached variables.
- *
- * @author Alexander Ebert
- * @copyright 2001-2013 WoltLab GmbH
- * @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 ICacheSource {
- /**
- * key prefix
- * @var string
- */
- protected $prefix = '';
-
- /**
- * Creates a new ApcCacheSource object.
- */
- public function __construct() {
- if (!function_exists('apc_store')) {
- throw new SystemException('APC support is not enabled.');
- }
-
- // set variable prefix to prevent collision
- $this->prefix = 'WCF_'.substr(sha1(WCF_DIR), 0, 10) . '_';
- }
-
- /**
- * @see \wcf\system\cache\source\ICacheSource::flush()
- */
- public function flush($cacheName, $useWildcard) {
- if ($useWildcard) {
- $this->removeKeys($this->prefix . $cacheName . '(\-[a-f0-9]+)?');
- }
- else {
- apc_delete($this->prefix . $cacheName);
- }
- }
-
- /**
- * @see \wcf\system\cache\source\ICacheSource::flushAll()
- */
- public function flushAll() {
- $this->removeKeys();
- }
-
- /**
- * @see \wcf\system\cache\source\ICacheSource::get()
- */
- public function get($cacheName, $maxLifetime) {
- if (($data = apc_fetch($this->prefix . $cacheName)) === false) {
- return null;
- }
-
- return $data;
- }
-
- /**
- * @see \wcf\system\cache\source\ICacheSource::set()
- */
- public function set($cacheName, $value, $maxLifetime) {
- apc_store($this->prefix . $cacheName, $value, $this->getTTL($maxLifetime));
- }
-
- /**
- * Returns time to live in seconds, defaults to 3 days.
- *
- * @param integer $maxLifetime
- * @return integer
- */
- protected function getTTL($maxLifetime = 0) {
- if ($maxLifetime) {
- // max lifetime is a timestamp, discard (similar to http://www.php.net/manual/en/memcached.expiration.php)
- if ($maxLifetime > (60 * 60 * 24 * 30)) {
- $maxLifetime = 0;
- }
- }
-
- if ($maxLifetime) {
- return $maxLifetime;
- }
-
- // default TTL: 3 days
- return (60 * 60 * 24 * 3);
- }
-
- /**
- * @see \wcf\system\cache\source\ICacheSource::clear()
- */
- public function removeKeys($pattern = null) {
- $regex = null;
- if ($pattern !== null) {
- $regex = new Regex('^'.$pattern.'$');
- }
-
- $apcCacheInfo = apc_cache_info('user');
- foreach ($apcCacheInfo['cache_list'] as $cache) {
- if ($regex === null) {
- if (StringUtil::startsWith($cache['info'], $this->prefix)) {
- apc_delete($cache['info']);
- }
- }
- else if ($regex->match($cache['info'])) {
- apc_delete($cache['info']);
- }
- }
- }
-}
<item name="wcf.acp.cache.list.name"><![CDATA[Name]]></item>
<item name="wcf.acp.cache.list.perm"><![CDATA[Zugriffsrechte]]></item>
<item name="wcf.acp.cache.list.size"><![CDATA[Größe]]></item>
- <item name="wcf.acp.cache.source.type.ApcCacheSource"><![CDATA[Alternative PHP Cache]]></item>
<item name="wcf.acp.cache.source.type.DiskCacheSource"><![CDATA[Dateisystem]]></item>
<item name="wcf.acp.cache.source.type.MemcachedCacheSource"><![CDATA[Memcached]]></item>
<item name="wcf.acp.cache.source.type.NoCacheSource"><![CDATA[keine (Caching deaktiviert)]]></item>
<item name="wcf.acp.option.cache_source_memcached_host"><![CDATA[Memcached-Server]]></item>
<item name="wcf.acp.option.cache_source_memcached_host.description"><![CDATA[Mehrere Server können zeilenweise angegeben und die Gewichtung als dritter Parameter angegeben werden, zum Beispiel „localhost:11211:67“ oder „10.0.13.37:31337:33“.]]></item>
<item name="wcf.acp.option.cache_source_type"><![CDATA[Cache-Methode]]></item>
- <item name="wcf.acp.option.cache_source_type.apc"><![CDATA[Alternative PHP Cache (experimentell)]]></item>
<item name="wcf.acp.option.cache_source_type.description"><![CDATA[Beachten Sie, dass einige Methoden spezielle Anforderungen an das Server-System stellen und nicht auf jedem Server zur Verfügung stehen.]]></item>
<item name="wcf.acp.option.cache_source_type.disk"><![CDATA[Dateisystem (Standard)]]></item>
<item name="wcf.acp.option.cache_source_type.memcached"><![CDATA[Memcached]]></item>
<item name="wcf.acp.cache.list.name"><![CDATA[Name]]></item>
<item name="wcf.acp.cache.list.perm"><![CDATA[Permissions]]></item>
<item name="wcf.acp.cache.list.size"><![CDATA[Size]]></item>
- <item name="wcf.acp.cache.source.type.ApcCacheSource"><![CDATA[Alternative PHP Cache]]></item>
<item name="wcf.acp.cache.source.type.DiskCacheSource"><![CDATA[Filesystem]]></item>
<item name="wcf.acp.cache.source.type.MemcachedCacheSource"><![CDATA[Memcached]]></item>
<item name="wcf.acp.cache.source.type.NoCacheSource"><![CDATA[None (caching disabled)]]></item>
<item name="wcf.acp.option.cache_source_memcached_host"><![CDATA[Memcached-Server]]></item>
<item name="wcf.acp.option.cache_source_memcached_host.description"><![CDATA[One server per line, you can additionally specify a weight factor to allow load balancing, for example “localhost:11211:67” or “10.0.13.37:31337:33”.]]></item>
<item name="wcf.acp.option.cache_source_type"><![CDATA[Caching Method]]></item>
- <item name="wcf.acp.option.cache_source_type.apc"><![CDATA[Alternative PHP Cache (experimental)]]></item>
<item name="wcf.acp.option.cache_source_type.description"><![CDATA[Caching methods different from “Filesystem” require special extensions or services running on your machine.]]></item>
<item name="wcf.acp.option.cache_source_type.disk"><![CDATA[Filesystem (default)]]></item>
<item name="wcf.acp.option.cache_source_type.memcached"><![CDATA[Memcached]]></item>