Commit 43f185f3 authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch '213526-size-caching' into 'master'

Expire snippet repo size caching

See merge request gitlab-org/gitlab!28994
parents befd7a23 f48aff81
......@@ -267,7 +267,7 @@ class Snippet < ApplicationRecord
def repository_size_checker
strong_memoize(:repository_size_checker) do
::Gitlab::RepositorySizeChecker.new(
current_size_proc: -> { repository._uncached_size.megabytes },
current_size_proc: -> { repository.size.megabytes },
limit: Gitlab::CurrentSettings.snippet_size_limit
)
end
......
......@@ -77,12 +77,8 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker
return false unless user
# At the moment, we only expires the repository caches.
# In the future we might need to call ProjectCacheWorker
# (or the custom class we create) to update the snippet
# repository size or any other key.
# We might also need to update the repository statistics.
expire_caches(post_received, snippet.repository)
snippet.repository.expire_statistics_caches
end
# Expire the repository status, branch, and tag cache once per push.
......
......@@ -703,7 +703,7 @@ describe Snippet do
let(:current_size) { 60 }
before do
allow(subject.repository).to receive(:_uncached_size).and_return(current_size)
allow(subject.repository).to receive(:size).and_return(current_size)
end
it 'sets up size checker', :aggregate_failures do
......
......@@ -394,6 +394,7 @@ describe PostReceive do
it 'expires the status cache' do
expect(snippet.repository).to receive(:empty?).and_return(true)
expect(snippet.repository).to receive(:expire_status_cache)
expect(snippet.repository).to receive(:expire_statistics_caches)
perform
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