Merge pull request #10000 from owncloud/fix-lowlat-cache-autoload
Cache factory needs to use globalPrefix in createLowLatency()
This commit is contained in:
commit
dd9347fdd2
28
lib/base.php
28
lib/base.php
|
@ -475,16 +475,9 @@ class OC {
|
||||||
@ini_set('file_uploads', '50');
|
@ini_set('file_uploads', '50');
|
||||||
|
|
||||||
self::handleAuthHeaders();
|
self::handleAuthHeaders();
|
||||||
|
|
||||||
self::initPaths();
|
self::initPaths();
|
||||||
if (OC_Config::getValue('instanceid', false)) {
|
self::registerAutoloaderCache();
|
||||||
// \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) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OC_Util::isSetLocaleWorking();
|
OC_Util::isSetLocaleWorking();
|
||||||
|
|
||||||
// setup 3rdparty autoloader
|
// 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
|
* Handle the request
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -59,7 +59,8 @@ class Factory implements ICacheFactory {
|
||||||
* @param string $prefix
|
* @param string $prefix
|
||||||
* @return null|Cache
|
* @return null|Cache
|
||||||
*/
|
*/
|
||||||
public static function createLowLatency($prefix = '') {
|
public function createLowLatency($prefix = '') {
|
||||||
|
$prefix = $this->globalPrefix . '/' . $prefix;
|
||||||
if (XCache::isAvailable()) {
|
if (XCache::isAvailable()) {
|
||||||
return new XCache($prefix);
|
return new XCache($prefix);
|
||||||
} elseif (APCu::isAvailable()) {
|
} elseif (APCu::isAvailable()) {
|
||||||
|
@ -76,7 +77,7 @@ class Factory implements ICacheFactory {
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isAvailableLowLatency() {
|
public function isAvailableLowLatency() {
|
||||||
return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable();
|
return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue