diff options
author | Stan Hu <stanhu@gmail.com> | 2019-03-07 17:19:56 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-03-12 09:03:38 -0700 |
commit | 0f7ed33759a2d995043beaf6ed99dd6bdac62dc2 (patch) | |
tree | 885e047a84fb82316b1650b008bb4aa3149f61a3 /app/models/repository.rb | |
parent | 121de6dc6f2aff66cc4068e1f34f0177ab5a9688 (diff) | |
download | gitlab-ce-0f7ed33759a2d995043beaf6ed99dd6bdac62dc2.tar.gz |
Cache Repository#root_ref within a request
When an empty project is loaded in the UI, there are 15 separate Gitaly
FindDefaultBranch calls to determine the root_ref. Previously, it was
not cached even within the request. This change caches it within the
request so only a single FindDefaultBranch RPC is needed.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/58684
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 851175a61b7..285fce1e6dd 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -534,10 +534,9 @@ class Repository end def root_ref - # When the repo does not exist, or there is no root ref, we raise this error so no data is cached. - raw_repository&.root_ref or raise Gitlab::Git::Repository::NoRepository # rubocop:disable Style/AndOr + raw_repository&.root_ref end - cache_method :root_ref + cache_method_asymmetrically :root_ref # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/314 def exists? |