Commit 87a1ba14 authored by Michael Kozono's avatar Michael Kozono

Expire RequestStore cache properly

parent 3640292b
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment