Skip to content

Commit e5c2be1

Browse files
authored
Merge pull request #54361 from nextcloud/backport/54357/stable31
[stable31] fix: increase how long we cache display names
2 parents dc699a2 + 30b36ef commit e5c2be1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/private/User/DisplayNameCache.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* @template-implements IEventListener<UserChangedEvent|UserDeletedEvent>
2525
*/
2626
class DisplayNameCache implements IEventListener {
27+
private const CACHE_TTL = 24 * 60 * 60; // 1 day
28+
2729
/** @see \OC\Config\UserConfig::USER_MAX_LENGTH */
2830
public const MAX_USERID_LENGTH = 64;
2931
private array $cache = [];
@@ -57,7 +59,7 @@ public function getDisplayName(string $userId): ?string {
5759
$displayName = null;
5860
}
5961
$this->cache[$userId] = $displayName;
60-
$this->memCache->set($userId, $displayName, 60 * 10); // 10 minutes
62+
$this->memCache->set($userId, $displayName, self::CACHE_TTL);
6163

6264
return $displayName;
6365
}
@@ -72,7 +74,7 @@ public function handle(Event $event): void {
7274
$userId = $event->getUser()->getUID();
7375
$newDisplayName = $event->getValue();
7476
$this->cache[$userId] = $newDisplayName;
75-
$this->memCache->set($userId, $newDisplayName, 60 * 10); // 10 minutes
77+
$this->memCache->set($userId, $newDisplayName, self::CACHE_TTL);
7678
}
7779
if ($event instanceof UserDeletedEvent) {
7880
$userId = $event->getUser()->getUID();

0 commit comments

Comments
 (0)