diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-07-02 08:00:30 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-07-02 08:00:30 +0000 |
commit | 1de68dc33fc7ed34c7f3d33c6186026c38c5b51a (patch) | |
tree | 1915bc44b6b077c94667678e0c3f17d6f4ec3f78 /lib | |
parent | a0481203d3ae2551325a8c197a1b9c090ba66b53 (diff) | |
parent | d4d6528c863d48c9e2d30e6b5927ef01ec35e0e3 (diff) | |
download | gitlab-ce-1de68dc33fc7ed34c7f3d33c6186026c38c5b51a.tar.gz |
Merge branch '44725-expire_correct_methods_after_change_head' into 'master'
Expire correct method caches after HEAD changed
Closes #44725
See merge request gitlab-org/gitlab-ce!20102
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/repository_cache_adapter.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/gitlab/repository_cache_adapter.rb b/lib/gitlab/repository_cache_adapter.rb index 7f64a8c9e46..2ec871f0754 100644 --- a/lib/gitlab/repository_cache_adapter.rb +++ b/lib/gitlab/repository_cache_adapter.rb @@ -25,6 +25,11 @@ module Gitlab raise NotImplementedError end + # List of cached methods. Should be overridden by the including class + def cached_methods + raise NotImplementedError + end + # Caches the supplied block both in a cache and in an instance variable. # # The cache key and instance variable are named the same way as the value of @@ -67,6 +72,11 @@ module Gitlab # Expires the caches of a specific set of methods def expire_method_caches(methods) methods.each do |key| + unless cached_methods.include?(key.to_sym) + Rails.logger.error "Requested to expire non-existent method '#{key}' for Repository" + next + end + cache.expire(key) ivar = cache_instance_variable_name(key) |