diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 0a39b00d9b..e167d5462c 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -18,9 +18,11 @@ class HomeController < BaseController private - # Cache the value of the query count for 24 hours + # Cache the value of the query count def cached_count(key, query) - Rails.cache.fetch("home_stats_count_#{key}", expires_in: 1.day, race_condition_ttl: 10) do + CacheService.cache("home_stats_count_#{key}", + expires_in: CacheService::HOME_STATS_EXPIRY, + race_condition_ttl: 10) do query.count end end diff --git a/app/services/cache_service.rb b/app/services/cache_service.rb index 36c33025f5..a68f883d0c 100644 --- a/app/services/cache_service.rb +++ b/app/services/cache_service.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class CacheService + HOME_STATS_EXPIRY = 1.day.freeze FILTERS_EXPIRY = 30.seconds.freeze def self.cache(cache_key, options = {})