From cf05369ca91ccae536a01bbb3a6f8bd7e5cfb14c Mon Sep 17 00:00:00 2001 From: Kristina Lim Date: Tue, 8 Oct 2019 14:37:25 +0800 Subject: [PATCH] Configure dalli store value max bytes from env variable --- config/application.yml.example | 2 ++ config/environments/production.rb | 4 +++- config/environments/staging.rb | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/application.yml.example b/config/application.yml.example index 96da545127..24ac9068fb 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -56,3 +56,5 @@ SMTP_PASSWORD: 'f00d' # STRIPE_INSTANCE_PUBLISHABLE_KEY: "pk_test_xxxx" # This can be a test key or a live key # STRIPE_CLIENT_ID: "ca_xxxx" # This can be a development ID or a production ID # STRIPE_ENDPOINT_SECRET: "whsec_xxxx" + +MEMCACHED_VALUE_MAX_MEGABYTES: 4 diff --git a/config/environments/production.rb b/config/environments/production.rb index 3d7803772d..af72e56b7d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -40,7 +40,9 @@ Openfoodnetwork::Application.configure do # config.logger = SyslogLogger.new # Use a different cache store in production - config.cache_store = :dalli_store + memcached_value_max_megabytes = ENV.fetch("MEMCACHED_VALUE_MAX_MEGABYTES", 1).to_i + memcached_value_max_bytes = memcached_value_max_megabytes * 1024 * 1024 + config.cache_store = :dalli_store, { value_max_bytes: memcached_value_max_bytes } # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" diff --git a/config/environments/staging.rb b/config/environments/staging.rb index b0e1b96301..936897b31b 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -40,7 +40,9 @@ Openfoodnetwork::Application.configure do # config.logger = SyslogLogger.new # Use a different cache store in production - config.cache_store = :dalli_store + memcached_value_max_megabytes = ENV.fetch("MEMCACHED_VALUE_MAX_MEGABYTES", 1).to_i + memcached_value_max_bytes = memcached_value_max_megabytes * 1024 * 1024 + config.cache_store = :dalli_store, { value_max_bytes: memcached_value_max_bytes } # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com"