From d6916eb5672320b44ffd53ffae61f68bdea3bcb8 Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Fri, 11 Apr 2025 09:18:23 +0200 Subject: fix(ldap): add random jitter to cache ttl Signed-off-by: Richard Steinmetz --- apps/user_ldap/lib/Connection.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 78a5f93d29e..1cf7f520a78 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -311,6 +311,9 @@ class Connection extends LDAPUtility { $key = $this->getCacheKey($key); $value = base64_encode(json_encode($value)); $ttl = $ttlOverride ?? $this->configuration->ldapCacheTTL; + // TODO: make jitter configurable (or disable)? + $ttlJitter = 0.1; + $ttl = random_int($ttl * (1 - $ttlJitter), $ttl * (1 + $ttlJitter)); $this->cache->set($key, $value, $ttl); } -- cgit v1.2.3