]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use cache to determine if value need to be updated
authorRoeland Jago Douma <roeland@famdouma.nl>
Thu, 13 Oct 2016 11:13:39 +0000 (13:13 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 13 Oct 2016 17:40:40 +0000 (19:40 +0200)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
lib/private/AllConfig.php

index 52d77bf3f52942d45384a35f341f6b372d69e170..af26d30d8e94e7caaa5d6815f54d043aea4b3504 100644 (file)
@@ -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 = [