Skip to content

Commit

Permalink
Enable redis-based caching in production
Browse files Browse the repository at this point in the history
Setting some pretty low-timeouts by default
  • Loading branch information
maxfierke committed Nov 5, 2023
1 parent 90bf9c5 commit a1ecdb0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@
# Use a different cache store in production.
# config.cache_store = :mem_cache_store

redis_url = ENV["CACHE_REDIS_URL"].presence || ENV["REDIS_URL"]
if redis_url.present?
config.cache_store = :redis_cache_store, {
url: redis_url,
connect_timeout: 1,
read_timeout: 0.2,
write_timeout: 0.2,
reconnect_attempts: 1,
}
end

# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "resumis_production"
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
redis_url = ENV['REDIS_URL'].presence || 'redis://localhost:6379/1'
redis_url = ENV["SIDEKIQ_REDIS_URL"].presence || ENV["REDIS_URL"].presence || 'redis://localhost:6379/1'
Sidekiq.configure_server do |config|
config.redis = { url: redis_url }
end
Expand Down

0 comments on commit a1ecdb0

Please sign in to comment.