]> source.dussan.org Git - nextcloud-server.git/commitdiff
cache the share owner name for formating cache entries 32050/head
authorRobin Appelman <robin@icewind.nl>
Thu, 21 Apr 2022 15:33:18 +0000 (17:33 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 21 Apr 2022 15:33:18 +0000 (17:33 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_sharing/lib/Cache.php

index 8729426221b934a7c25b42a368e5670c8709fb8e..c49bebaef62d9bb262079ade1c2ce16929892b61 100644 (file)
@@ -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;