Skip to content

Commit

Permalink
Merge pull request #617 from codeforjapan/use-redis-for-cache-and-ses…
Browse files Browse the repository at this point in the history
…sion

use redis for cache and session store
  • Loading branch information
ayuki-joto authored Jul 29, 2024
2 parents d7653b8 + db81eea commit bac64d8
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 bac64d8

Please sign in to comment.