diff --git a/apps/encryption/tests/MigrationTest.php b/apps/encryption/tests/MigrationTest.php
index 868a1ad3922a0655200a205a43532dee18ecf24c..595d7f12067b87f8037e8bff2eb2387db4a6aea3 100644
--- a/apps/encryption/tests/MigrationTest.php
+++ b/apps/encryption/tests/MigrationTest.php
@@ -343,6 +343,10 @@ class MigrationTest extends \Test\TestCase {
 		unset($cache['files_encryption']);
 		$this->invokePrivate(\OC::$server->getAppConfig(), 'cache', [$cache]);
 
+		$cache = $this->invokePrivate($config, 'userCache');
+		unset($cache[self::TEST_ENCRYPTION_MIGRATION_USER1]);
+		$this->invokePrivate(\OC::$server->getAppConfig(), 'userCache', [$cache]);
+
 		// delete default values set by the encryption app during initialization
 
 		/** @var \OCP\IDBConnection $connection */
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php
index 52d77bf3f52942d45384a35f341f6b372d69e170..af26d30d8e94e7caaa5d6815f54d043aea4b3504 100644
--- a/lib/private/AllConfig.php
+++ b/lib/private/AllConfig.php
@@ -215,6 +215,25 @@ class AllConfig implements \OCP\IConfig {
 		// TODO - FIXME
 		$this->fixDIInit();
 
+		if (isset($this->userCache[$userId][$appName][$key])) {
+			if ($this->userCache[$userId][$appName][$key] === (string)$value) {
+				return;
+			} else if ($preCondition !== null && $this->userCache[$userId][$appName][$key] !== (string)$preCondition) {
+				return;
+			} else {
+				$qb = $this->connection->getQueryBuilder();
+				$qb->update('preferences')
+					->set('configvalue', $qb->createNamedParameter($value))
+					->where($qb->expr()->eq('userid', $qb->createNamedParameter($userId)))
+					->andWhere($qb->expr()->eq('appid', $qb->createNamedParameter($appName)))
+					->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter($key)));
+				$qb->execute();
+
+				$this->userCache[$userId][$appName][$key] = $value;
+				return;
+			}
+		}
+
 		$preconditionArray = [];
 		if (isset($preCondition)) {
 			$preconditionArray = [