diff --git a/config/environments/development.rb b/config/environments/development.rb index bcc255982e..3cbfd12b71 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -19,7 +19,11 @@ if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true - config.cache_store = :memory_store + if ENV["REDIS_CACHE_URL"] # rubocop:disable Style/ConditionalAssignment + config.cache_store = :redis_cache_store, { url: ENV.fetch("REDIS_CACHE_URL", nil) } + else + config.cache_store = :memory_store + end config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } diff --git a/config/environments/production.rb b/config/environments/production.rb index 37dd365d10..6c1f2f8fb5 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -51,6 +51,7 @@ # Use a different cache store in production. # config.cache_store = :mem_cache_store + config.cache_store = :redis_cache_store, { url: ENV.fetch("REDIS_CACHE_URL", nil) } # Use a real queuing backend for Active Job (and separate queues per environment) # config.active_job.queue_adapter = :resque diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb new file mode 100644 index 0000000000..efcb38536e --- /dev/null +++ b/config/initializers/session_store.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +Rails.application.config.to_prepare do + Rails.application.config.session_store :cache_store if ENV["REDIS_CACHE_URL"] +end