summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2018-09-25 10:12:51 -0700
committerMichael Kozono <mkozono@gmail.com>2018-09-27 18:22:37 -0700
commit3640292bf2ef822c8e2394fa2397b1b7d04e9891 (patch)
treee6083dca766e7acfb94b613329a43c98a8aa526b /app
parentd9c4ebc5a0b2e911f17865e482de1dfcc2189ac3 (diff)
downloadgitlab-ce-3640292bf2ef822c8e2394fa2397b1b7d04e9891.tar.gz
Cache `Repository#exists?` false in RequestStore
* Only truthy values are cached in Redis. * All values are cached in RequestStore and in an instance variable.
Diffstat (limited to 'app')
-rw-r--r--app/models/repository.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 7a6dfada917..4fecdb3c1ad 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -510,7 +510,7 @@ class Repository
raw_repository.exists?
end
- cache_method :exists?
+ cache_method_asymmetrically :exists?
# We don't need to cache the output of this method because both exists? and
# has_visible_content? are already memoized and cached. There's no guarantee
@@ -1029,6 +1029,10 @@ class Repository
@cache ||= Gitlab::RepositoryCache.new(self)
end
+ def request_store_cache
+ @request_store_cache ||= Gitlab::RepositoryCache.new(self, backend: Gitlab::SafeRequestStore)
+ end
+
def tags_sorted_by_committed_date
tags.sort_by do |tag|
# Annotated tags can point to any object (e.g. a blob), but generally