Commit 563b40e4 authored by Stan Hu's avatar Stan Hu

Merge branch 'bw-count-service-cache-options' into 'master'

allow caching options to be specified for counting services

See merge request gitlab-org/gitlab-ce!15651
parents bfac8b7a e292bf5b
......@@ -9,7 +9,7 @@ class BaseCountService
end
def count
Rails.cache.fetch(cache_key, raw: raw?) { uncached_count }.to_i
Rails.cache.fetch(cache_key, cache_options) { uncached_count }.to_i
end
def refresh_cache
......@@ -31,4 +31,10 @@ class BaseCountService
def cache_key
raise NotImplementedError, 'cache_key must be implemented and return a String'
end
# subclasses can override to add any specific options, such as
# super.merge({ expires_in: 5.minutes })
def cache_options
{ raw: raw? }
end
end
......@@ -77,4 +77,10 @@ describe BaseCountService, :use_clean_rails_memory_store_caching do
expect { service.cache_key }.to raise_error(NotImplementedError)
end
end
describe '#cache_options' do
it 'returns the default in options' do
expect(service.cache_options).to eq({ raw: false })
end
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