Provide a way of using Redis for Rails cache
This commit is contained in:
parent
22013791c3
commit
42a78cd286
1
Gemfile
1
Gemfile
|
@ -60,6 +60,7 @@ gem "sanitize"
|
|||
|
||||
gem "twitter-text"
|
||||
|
||||
gem "connection_pool"
|
||||
gem "redis"
|
||||
|
||||
gem "fake_email_validator"
|
||||
|
|
|
@ -489,6 +489,7 @@ DEPENDENCIES
|
|||
carrierwave (~> 2.0)
|
||||
carrierwave_backgrounder!
|
||||
colorize
|
||||
connection_pool
|
||||
cssbundling-rails (~> 1.1)
|
||||
database_cleaner
|
||||
devise (~> 4.0)
|
||||
|
|
|
@ -54,7 +54,19 @@ Rails.application.configure do
|
|||
config.lograge.enabled = true
|
||||
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
cache_redis_url = ENV.fetch("CACHE_REDIS_URL") { nil }
|
||||
if cache_redis_url.present?
|
||||
config.cache_store = :redis_cache_store, {
|
||||
url: cache_redis_url,
|
||||
pool_size: ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i,
|
||||
pool_timeout: ENV.fetch("CACHE_REDIS_TIMEOUT") { 5 },
|
||||
error_handler: -> (method:, returning:, exception:) {
|
||||
# Report errors to Sentry as warnings
|
||||
Sentry.capture_exception exception, level: 'warning',
|
||||
tags: { method: method, returning: returning }
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
# Use a real queuing backend for Active Job (and separate queues per environment)
|
||||
# config.active_job.queue_adapter = :resque
|
||||
|
|
Loading…
Reference in New Issue