diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-07-30 16:56:45 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-07-30 16:56:45 +0200 |
commit | dd9347fdd2b1f516ee71d3fb9bbc391541a6d5dc (patch) | |
tree | 15f5fce9d3b0a19c698fd5ea5e21299fb17da705 | |
parent | 38e309b0fe5f18c22a6f1b175ff24345e78f1548 (diff) | |
parent | a8fbc709ce141257df1c1edf3eac3bb154db29a5 (diff) | |
download | nextcloud-server-dd9347fdd2b1f516ee71d3fb9bbc391541a6d5dc.tar.gz nextcloud-server-dd9347fdd2b1f516ee71d3fb9bbc391541a6d5dc.zip |
Merge pull request #10000 from owncloud/fix-lowlat-cache-autoload
Cache factory needs to use globalPrefix in createLowLatency()
-rw-r--r-- | lib/base.php | 28 | ||||
-rw-r--r-- | lib/private/memcache/factory.php | 5 |
2 files changed, 22 insertions, 11 deletions
diff --git a/lib/base.php b/lib/base.php index afa498e502e..6751f897dfc 100644 --- a/lib/base.php +++ b/lib/base.php @@ -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 */ diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php index d60b157efe2..8e47a8899fc 100644 --- a/lib/private/memcache/factory.php +++ b/lib/private/memcache/factory.php @@ -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(); } |