Merge pull request #10000 from owncloud/fix-lowlat-cache-autoload

Cache factory needs to use globalPrefix in createLowLatency()
This commit is contained in:
Jörn Friedrich Dreyer 2014-07-30 16:56:45 +02:00
commit dd9347fdd2
2 changed files with 22 additions and 11 deletions

View File

@ -475,16 +475,9 @@ class OC {
@ini_set('file_uploads', '50');
self::handleAuthHeaders();
self::initPaths();
if (OC_Config::getValue('instanceid', false)) {
// \OC\Memcache\Cache has a hidden dependency on
// OC_Util::getInstanceId() for namespacing. See #5409.
try {
self::$loader->setMemoryCache(\OC\Memcache\Factory::createLowLatency('Autoloader'));
} catch (\Exception $ex) {
}
}
self::registerAutoloaderCache();
OC_Util::isSetLocaleWorking();
// setup 3rdparty autoloader
@ -644,6 +637,23 @@ class OC {
}
}
protected static function registerAutoloaderCache() {
// The class loader takes an optional low-latency cache, which MUST be
// namespaced. The instanceid is used for namespacing, but might be
// unavailable at this point. Futhermore, it might not be possible to
// generate an instanceid via \OC_Util::getInstanceId() because the
// config file may not be writable. As such, we only register a class
// loader cache if instanceid is available without trying to create one.
$instanceId = OC_Config::getValue('instanceid', null);
if ($instanceId) {
try {
$memcacheFactory = new \OC\Memcache\Factory($instanceId);
self::$loader->setMemoryCache($memcacheFactory->createLowLatency('Autoloader'));
} catch (\Exception $ex) {
}
}
}
/**
* Handle the request
*/

View File

@ -59,7 +59,8 @@ class Factory implements ICacheFactory {
* @param string $prefix
* @return null|Cache
*/
public static function createLowLatency($prefix = '') {
public function createLowLatency($prefix = '') {
$prefix = $this->globalPrefix . '/' . $prefix;
if (XCache::isAvailable()) {
return new XCache($prefix);
} elseif (APCu::isAvailable()) {
@ -76,7 +77,7 @@ class Factory implements ICacheFactory {
*
* @return bool
*/
public static function isAvailableLowLatency() {
public function isAvailableLowLatency() {
return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable();
}