Merge pull request #3595 from coopdevs/instrument-products-cache

Instrument products cache
This commit is contained in:
Pau Pérez Fabregat
2019-03-14 18:58:43 +01:00
committed by GitHub
4 changed files with 14 additions and 3 deletions

View File

@@ -54,5 +54,5 @@ Spree::AppConfiguration.class_eval do
preference :enable_localized_number?, :boolean, default: false
# Enable cache
preference :enable_products_cache?, :boolean, default: true
preference :enable_products_cache?, :boolean, default: !Rails.env.development?
end

View File

@@ -5,7 +5,9 @@ Openfoodnetwork::Application.configure do
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
config.cache_store = :memory_store
# :file_store is used by default when no cache store is specifically configured.
# config.cache_store = :file_store
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
@@ -40,4 +42,6 @@ Openfoodnetwork::Application.configure do
# Show emails using Letter Opener
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.default_url_options = { host: "0.0.0.0:3000" }
config.log_level = :debug
end

View File

@@ -0,0 +1,7 @@
unless Rails.env.production?
# Enable cache instrumentation, which is disabled by default
ActiveSupport::Cache::Store.instrument = true
# Log message in the same default logger
ActiveSupport::Cache::Store.logger = Rails.logger
end

View File

@@ -39,7 +39,7 @@ module OpenFoodNetwork
end
def use_cached_products?
Spree::Config[:enable_products_cache?] && (Rails.env.production? || Rails.env.staging?)
Spree::Config[:enable_products_cache?]
end
def uncached_products_json