diff --git a/lib/base.php b/lib/base.php
index be0955090e07d3c96ea84c49ce8165994606d6aa..e856574942527b131d0e2671ab3e45b78deac3aa 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -477,9 +477,18 @@ class OC {
 		self::handleAuthHeaders();
 
 		self::initPaths();
-		if (OC_Config::getValue('instanceid', false)) {
+
+		// 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 {
-				self::$loader->setMemoryCache(\OC\Memcache\Factory::createLowLatency('Autoloader'));
+				$memcacheFactory = new \OC\Memcache\Factory($instanceId);
+				self::$loader->setMemoryCache($memcacheFactory->createLowLatency('Autoloader'));
 			} catch (\Exception $ex) {
 			}
 		}
diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php
index d60b157efe240a40a0c154813d9b2be80f06c08e..8e47a8899fcab9e3ac0409c36534abffd2f5d135 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();
 	}