diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-19 21:10:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-19 21:10:34 +0300 |
commit | 2f5731cf536deff075d1011814f271cbb1ed67e2 (patch) | |
tree | f6e6dec098a60039b1413dae64d24c0bf55bf03d /lib/gitlab/repository_cache_adapter.rb | |
parent | 74b5b3ffcb9fe4d9424bc2bf35e43f749f76d023 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/repository_cache_adapter.rb')
-rw-r--r-- | lib/gitlab/repository_cache_adapter.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/gitlab/repository_cache_adapter.rb b/lib/gitlab/repository_cache_adapter.rb index da8025d2265..f6a5c6ed754 100644 --- a/lib/gitlab/repository_cache_adapter.rb +++ b/lib/gitlab/repository_cache_adapter.rb @@ -58,11 +58,19 @@ module Gitlab # wrong answer. We handle that by querying the full list - which fills # the cache - and using it directly to answer the question. define_method("#{name}_include?") do |value| - if strong_memoized?(name) || !redis_set_cache.exist?(name) - return __send__(name).include?(value) # rubocop:disable GitlabSecurity/PublicSend - end + ivar = "@#{name}_include" + memoized = instance_variable_get(ivar) || {} + + next memoized[value] if memoized.key?(value) + + memoized[value] = + if strong_memoized?(name) || !redis_set_cache.exist?(name) + __send__(name).include?(value) # rubocop:disable GitlabSecurity/PublicSend + else + redis_set_cache.include?(name, value) + end - redis_set_cache.include?(name, value) + instance_variable_set(ivar, memoized)[value] end end |