diff --git a/Gemfile b/Gemfile index 8afdfa339b..609730d223 100644 --- a/Gemfile +++ b/Gemfile @@ -82,6 +82,9 @@ gem 'rack-rewrite' gem 'rack-ssl', require: 'rack/ssl' gem 'roadie-rails', '~> 2.2.0' +gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis'] +gem 'hiredis' + gem 'combine_pdf' gem 'wicked_pdf' gem 'wkhtmltopdf-binary' diff --git a/Gemfile.lock b/Gemfile.lock index 5abecb6a85..8abfe2d20f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -285,6 +285,7 @@ GEM tilt hashdiff (1.0.1) highline (2.0.3) + hiredis (0.6.3) i18n (1.8.10) concurrent-ruby (~> 1.0) i18n-js (3.8.2) @@ -447,6 +448,7 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) redcarpet (3.5.1) + redis (4.2.5) regexp_parser (2.1.1) request_store (1.5.0) rack (>= 1.4) @@ -672,6 +674,7 @@ DEPENDENCIES good_migrations haml highline (= 2.0.3) + hiredis i18n i18n-js (~> 3.8.2) immigrant @@ -706,6 +709,7 @@ DEPENDENCIES rails_safe_tasks (~> 1.0) ransack (= 2.4.1) redcarpet + redis (>= 4.0) responders roadie-rails (~> 2.2.0) roo (~> 2.8.3) diff --git a/config/application.yml.example b/config/application.yml.example index 2b93ead158..1346dae4c2 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -66,5 +66,3 @@ SMTP_PASSWORD: 'f00d' # config/initializers/feature_toggles.rb for details. # # BETA_TESTERS: ofn@example.com,superadmin@example.com - -MEMCACHED_VALUE_MAX_MEGABYTES: '4' diff --git a/config/environments/development.rb b/config/environments/development.rb index 72c6e7d7cb..3b22ee205f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -11,7 +11,14 @@ Openfoodnetwork::Application.configure do config.cache_classes = !!ENV["PROFILE"] # :file_store is used by default when no cache store is specifically configured. - config.cache_store = :memory_store if !!ENV["PROFILE"] + if !!ENV["PROFILE"] + config.cache_store = :redis_cache_store, { + driver: :hiredis, + url: ENV.fetch("OFN_REDIS_URL", "redis://localhost:6379/0"), + namespace: "cache", + expires_in: 90.minutes + } + end config.eager_load = false diff --git a/config/environments/production.rb b/config/environments/production.rb index 826a4de616..472f47c050 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -42,9 +42,12 @@ Openfoodnetwork::Application.configure do config.log_formatter = Logger::Formatter.new.tap { |f| f.datetime_format = "%Y-%m-%d %H:%M:%S" } # Use a different cache store in production - 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 = :mem_cache_store, { value_max_bytes: memcached_value_max_bytes } + config.cache_store = :redis_cache_store, { + driver: :hiredis, + url: ENV.fetch("OFN_REDIS_URL", "redis://localhost:6379/0"), + namespace: "cache", + reconnect_attempts: 1 + } # 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 826a4de616..472f47c050 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -42,9 +42,12 @@ Openfoodnetwork::Application.configure do config.log_formatter = Logger::Formatter.new.tap { |f| f.datetime_format = "%Y-%m-%d %H:%M:%S" } # Use a different cache store in production - 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 = :mem_cache_store, { value_max_bytes: memcached_value_max_bytes } + config.cache_store = :redis_cache_store, { + driver: :hiredis, + url: ENV.fetch("OFN_REDIS_URL", "redis://localhost:6379/0"), + namespace: "cache", + reconnect_attempts: 1 + } # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com"