diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-08-23 11:58:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 11:58:02 +0200 |
commit | 232866d42ed25150358c17a0dda1a4ac0c058961 (patch) | |
tree | c77b36ad8c5f9cfc3ddcdbb2aaecf7cf61a8c129 /lib | |
parent | 385f3c0135e0eadf87c46b4cc4f794f3c075f1de (diff) | |
parent | 5edab8c9228db86efbe0f8dd44b7f43c3ed3b34d (diff) | |
download | nextcloud-server-232866d42ed25150358c17a0dda1a4ac0c058961.tar.gz nextcloud-server-232866d42ed25150358c17a0dda1a4ac0c058961.zip |
Merge pull request #33595 from nextcloud/fix/cache-profile-config
Cache ConfigProfile
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Profile/ProfileManager.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/private/Profile/ProfileManager.php b/lib/private/Profile/ProfileManager.php index f2eacd1ef25..f038986cf6d 100644 --- a/lib/private/Profile/ProfileManager.php +++ b/lib/private/Profile/ProfileManager.php @@ -44,6 +44,7 @@ use OCP\IConfig; use OCP\IUser; use OCP\L10N\IFactory; use OCP\Profile\ILinkAction; +use OCP\Cache\CappedMemoryCache; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; @@ -81,6 +82,8 @@ class ProfileManager { /** @var null|ILinkAction[] */ private $sortedActions = null; + /** @var CappedMemoryCache<ProfileConfig> */ + private CappedMemoryCache $configCache; private const CORE_APP_ID = 'core'; @@ -127,6 +130,7 @@ class ProfileManager { $this->l10nFactory = $l10nFactory; $this->logger = $logger; $this->coordinator = $coordinator; + $this->configCache = new CappedMemoryCache(); } /** @@ -370,7 +374,10 @@ class ProfileManager { public function getProfileConfig(IUser $targetUser, ?IUser $visitingUser): array { $defaultProfileConfig = $this->getDefaultProfileConfig($targetUser, $visitingUser); try { - $config = $this->configMapper->get($targetUser->getUID()); + if (($config = $this->configCache[$targetUser->getUID()]) === null) { + $config = $this->configMapper->get($targetUser->getUID()); + $this->configCache[$targetUser->getUID()] = $config; + } // Merge defaults with the existing config in case the defaults are missing $config->setConfigArray(array_merge( $defaultProfileConfig, |