Skip to content

Commit

Permalink
use redis for cache and session store
Browse files Browse the repository at this point in the history
  • Loading branch information
takahashim committed Jul 24, 2024
1 parent eae919b commit db81eea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
Expand Down
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit db81eea

Please sign in to comment.