Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Walker <brett@digitalmoksha.com>2017-12-01 01:23:07 +0300
committerStan Hu <stanhu@gmail.com>2017-12-01 01:23:07 +0300
commite292bf5b88843a6d03ca178d3b0c4f70ecff70a6 (patch)
treeb795355903deeb56ba3f8dd3e6dd289f6926e62b /app/services/base_count_service.rb
parentbfac8b7abab72ad3a8c6eefeb5ef220da4b5aaa2 (diff)
allow caching options to be specified for counting services
Diffstat (limited to 'app/services/base_count_service.rb')
-rw-r--r--app/services/base_count_service.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/base_count_service.rb b/app/services/base_count_service.rb
index 99cc9a196e6..19873fe09a5 100644
--- a/app/services/base_count_service.rb
+++ b/app/services/base_count_service.rb
@@ -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