Commit a6f41c64 authored by Sean McGivern's avatar Sean McGivern
Browse files

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 98d834919730
...@@ -72,7 +72,7 @@ def highlight_cache ...@@ -72,7 +72,7 @@ def highlight_cache
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 @@ ...@@ -15,7 +15,7 @@
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 @@ ...@@ -31,7 +31,7 @@
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