Skip to content

Commit

Permalink
Throw an exception if redis down in development (#3208)
Browse files Browse the repository at this point in the history
When testing a recent PR in dev, I was not connected to
redis. Instead of give me a warning, the app switched to
null store which caused me to waste a bunch of Albert's
time asking why a PR didn't work.

With this change, if we can't connect to redis, we throw
an exception. Also, in general, if there are any issues with
redis this will also throw an exception which is desirable in
development.
  • Loading branch information
tsmartt committed May 3, 2021
1 parent a1020bc commit 3ae1c8f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@
config.consider_all_requests_local = true

# Enable/disable caching. By default caching is disabled.
if Rails.application.secrets[:redis_url]
config.action_controller.perform_caching = true
config.cache_store = :redis_cache_store, { url: Rails.application.secrets[:redis_url] }
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=172800"
config.action_controller.perform_caching = true
config.cache_store =
:redis_cache_store, {
url: Rails.application.secrets[:redis_url],
error_handler: -> (method:, returning:, exception:) { raise exception },
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=172800",
}

require 'connection_pool'
REDIS = ConnectionPool.new(size: 5) { Redis.new }
Expand Down

0 comments on commit 3ae1c8f

Please sign in to comment.