mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #54361 from nextcloud/backport/54357/stable31
[stable31] fix: increase how long we cache display names
This commit is contained in:
commit
e5c2be1f54
1 changed files with 4 additions and 2 deletions
|
|
@ -24,6 +24,8 @@ use OCP\User\Events\UserDeletedEvent;
|
|||
* @template-implements IEventListener<UserChangedEvent|UserDeletedEvent>
|
||||
*/
|
||||
class DisplayNameCache implements IEventListener {
|
||||
private const CACHE_TTL = 24 * 60 * 60; // 1 day
|
||||
|
||||
/** @see \OC\Config\UserConfig::USER_MAX_LENGTH */
|
||||
public const MAX_USERID_LENGTH = 64;
|
||||
private array $cache = [];
|
||||
|
|
@ -57,7 +59,7 @@ class DisplayNameCache implements IEventListener {
|
|||
$displayName = null;
|
||||
}
|
||||
$this->cache[$userId] = $displayName;
|
||||
$this->memCache->set($userId, $displayName, 60 * 10); // 10 minutes
|
||||
$this->memCache->set($userId, $displayName, self::CACHE_TTL);
|
||||
|
||||
return $displayName;
|
||||
}
|
||||
|
|
@ -72,7 +74,7 @@ class DisplayNameCache implements IEventListener {
|
|||
$userId = $event->getUser()->getUID();
|
||||
$newDisplayName = $event->getValue();
|
||||
$this->cache[$userId] = $newDisplayName;
|
||||
$this->memCache->set($userId, $newDisplayName, 60 * 10); // 10 minutes
|
||||
$this->memCache->set($userId, $newDisplayName, self::CACHE_TTL);
|
||||
}
|
||||
if ($event instanceof UserDeletedEvent) {
|
||||
$userId = $event->getUser()->getUID();
|
||||
|
|
|
|||
Loading…
Reference in a new issue