Commit db908826 authored by Sean McGivern's avatar Sean McGivern

Only cache MR diffs for one week

This may lead to some being evicted and having to be cached again, but many MRs
get closed or updated in that time anyway.
parent 6cd7f679
...@@ -72,7 +72,7 @@ module Gitlab ...@@ -72,7 +72,7 @@ module Gitlab
end end
def store_highlight_cache def store_highlight_cache
Rails.cache.write(cache_key, highlight_cache) if @highlight_cache_was_empty Rails.cache.write(cache_key, highlight_cache, expires_in: 1.week) if @highlight_cache_was_empty
end end
def cacheable?(diff_file) def cacheable?(diff_file)
......
...@@ -15,7 +15,7 @@ describe MergeRequests::MergeRequestDiffCacheService, :use_clean_rails_memory_st ...@@ -15,7 +15,7 @@ describe MergeRequests::MergeRequestDiffCacheService, :use_clean_rails_memory_st
cache_key = new_diff.diffs.cache_key cache_key = new_diff.diffs.cache_key
expect(Rails.cache).to receive(:read).with(cache_key).and_call_original expect(Rails.cache).to receive(:read).with(cache_key).and_call_original
expect(Rails.cache).to receive(:write).with(cache_key, anything).and_call_original expect(Rails.cache).to receive(:write).with(cache_key, anything, anything).and_call_original
subject.execute(merge_request, new_diff) subject.execute(merge_request, new_diff)
end end
...@@ -31,7 +31,7 @@ describe MergeRequests::MergeRequestDiffCacheService, :use_clean_rails_memory_st ...@@ -31,7 +31,7 @@ describe MergeRequests::MergeRequestDiffCacheService, :use_clean_rails_memory_st
expect(Rails.cache).to receive(:delete).with(old_cache_key).and_call_original expect(Rails.cache).to receive(:delete).with(old_cache_key).and_call_original
expect(Rails.cache).to receive(:read).with(new_cache_key).and_call_original expect(Rails.cache).to receive(:read).with(new_cache_key).and_call_original
expect(Rails.cache).to receive(:write).with(new_cache_key, anything).and_call_original expect(Rails.cache).to receive(:write).with(new_cache_key, anything, anything).and_call_original
subject.execute(merge_request, new_diff) subject.execute(merge_request, new_diff)
end end
......
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