Expire RequestStore cache properly
This commit is contained in:
parent
3640292bf2
commit
87a1ba1488
|
@ -136,6 +136,8 @@ module Gitlab
|
|||
|
||||
clear_memoization(memoizable_name(name))
|
||||
end
|
||||
|
||||
expire_request_store_method_caches(methods)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -144,6 +146,12 @@ module Gitlab
|
|||
"#{name.to_s.tr('?!', '')}"
|
||||
end
|
||||
|
||||
def expire_request_store_method_caches(methods)
|
||||
methods.each do |name|
|
||||
request_store_cache.expire(name)
|
||||
end
|
||||
end
|
||||
|
||||
# All cached repository methods depend on the existence of a Git repository,
|
||||
# so if the repository doesn't exist, we already know not to call it.
|
||||
def fallback_early?(method_name)
|
||||
|
|
|
@ -1757,12 +1757,19 @@ describe Repository do
|
|||
|
||||
describe '#expire_exists_cache' do
|
||||
let(:cache) { repository.send(:cache) }
|
||||
let(:request_store_cache) { repository.send(:request_store_cache) }
|
||||
|
||||
it 'expires the cache' do
|
||||
expect(cache).to receive(:expire).with(:exists?)
|
||||
|
||||
repository.expire_exists_cache
|
||||
end
|
||||
|
||||
it 'expires the request store cache', :request_store do
|
||||
expect(request_store_cache).to receive(:expire).with(:exists?)
|
||||
|
||||
repository.expire_exists_cache
|
||||
end
|
||||
end
|
||||
|
||||
describe '#xcode_project?' do
|
||||
|
|
Loading…
Reference in New Issue