diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-12-20 17:19:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-20 17:19:56 +0100 |
commit | 13d5426893b4a5d7f0e81707d832e4d5b8f5cb06 (patch) | |
tree | 23d28bd3c033a4a2706ff04ed26f772519b531c0 /apps/user_ldap/lib | |
parent | 3bcbc4701a0f0bd4800fd7f89403e578a610fd0b (diff) | |
parent | 1ac2c748302b3ebe846bae8592a35abaf83ff41c (diff) | |
download | nextcloud-server-13d5426893b4a5d7f0e81707d832e4d5b8f5cb06.tar.gz nextcloud-server-13d5426893b4a5d7f0e81707d832e4d5b8f5cb06.zip |
Merge pull request #35839 from nextcloud/feat/user_ldap-longer-ttl-for-fallback
Apply a longer TTL of 15min to falling back on backup server
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/Connection.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 95ddd3fc51c..6700890c8c7 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -292,7 +292,7 @@ class Connection extends LDAPUtility { * @param string $key * @param mixed $value */ - public function writeToCache($key, $value): void { + public function writeToCache($key, $value, int $ttlOverride = null): void { if (!$this->configured) { $this->readConfiguration(); } @@ -303,7 +303,8 @@ class Connection extends LDAPUtility { } $key = $this->getCacheKey($key); $value = base64_encode(json_encode($value)); - $this->cache->set($key, $value, $this->configuration->ldapCacheTTL); + $ttl = $ttlOverride ?? $this->configuration->ldapCacheTTL; + $this->cache->set($key, $value, $ttl); } public function clearCache() { @@ -635,8 +636,8 @@ class Connection extends LDAPUtility { $this->ldap->errno($this->ldapConnectionRes) : -1; if ($bindStatus && $error === 0 && !$forceBackupHost) { //when bind to backup server succeeded and failed to main server, - //skip contacting him until next cache refresh - $this->writeToCache($overrideCacheKey, true); + //skip contacting it for 15min + $this->writeToCache($overrideCacheKey, true, 60 * 15); } return $bindStatus; |