mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #3595 from coopdevs/instrument-products-cache
Instrument products cache
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
7
config/initializers/cache_store.rb
Normal file
7
config/initializers/cache_store.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user