diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2022-04-22 08:13:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 08:13:38 +0200 |
commit | 54532b2df399d747c2d2e1309fd2ede03cce44ff (patch) | |
tree | 8362fead345b62b9eae3ab1c804581636adb7d75 /apps | |
parent | 3eb7c9d717cae0013d9eb1a78ff8ee15ac8bc1df (diff) | |
parent | 1f1b2a32cbc6f7d3416368ab835bd3f892ea8c71 (diff) | |
download | nextcloud-server-54532b2df399d747c2d2e1309fd2ede03cce44ff.tar.gz nextcloud-server-54532b2df399d747c2d2e1309fd2ede03cce44ff.zip |
Merge pull request #32050 from nextcloud/share-cache-owner-name
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/Cache.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index 8729426221b..c49bebaef62 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -38,6 +38,7 @@ use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchComparison; use OCP\Files\Search\ISearchOperator; use OCP\Files\StorageNotAvailableException; +use OCP\ICacheFactory; use OCP\IUserManager; /** @@ -172,12 +173,21 @@ class Cache extends CacheJail { private function getOwnerDisplayName() { if (!$this->ownerDisplayName) { + /** @var ICacheFactory $cacheFactory */ + $cacheFactory = \OC::$server->get(ICacheFactory::class); + $memcache = $cacheFactory->createLocal('share_owner_name'); $uid = $this->storage->getOwner(''); - $user = $this->userManager->get($uid); - if ($user) { - $this->ownerDisplayName = $user->getDisplayName(); + $cached = $memcache->get($uid); + if ($cached) { + $this->ownerDisplayName = $cached; } else { - $this->ownerDisplayName = $uid; + $user = $this->userManager->get($uid); + if ($user) { + $this->ownerDisplayName = $user->getDisplayName(); + } else { + $this->ownerDisplayName = $uid; + } + $memcache->set($uid, $this->ownerDisplayName, 60 * 60); } } return $this->ownerDisplayName; |