Don't update value if it is already set to the same value

* this PR makes sure to warm up the cache for that user
* then the logic within the "if is in cache" code can be used to reduce needed queries
* inspired by @andreas-p - https://github.com/nextcloud/server/pull/2128

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
pull/2147/head
Morris Jobke 10 years ago committed by Roeland Jago Douma
parent cc8750ca30
commit 2960b97fc7
No known key found for this signature in database
GPG Key ID: F941078878347C0C
  1. 5
      lib/private/AllConfig.php

@ -215,11 +215,14 @@ class AllConfig implements \OCP\IConfig {
// TODO - FIXME
$this->fixDIInit();
// warm up the cache to avoid updating the value if it is already set to this value before
$this->getUserValue($userId, $appName, $key);
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;
throw new PreConditionNotMetException();
} else {
$qb = $this->connection->getQueryBuilder();
$qb->update('preferences')

Loading…
Cancel
Save