forked from External/greenlight
Switched to Redis cache in production (#761)
This commit is contained in:
parent
d3eb064b96
commit
cfab2fd191
4
Gemfile
4
Gemfile
|
@ -83,6 +83,10 @@ group :production do
|
|||
|
||||
# For a better logging library in production
|
||||
gem "lograge"
|
||||
|
||||
# Use for the cache store in production
|
||||
gem 'redis'
|
||||
gem 'hiredis'
|
||||
end
|
||||
|
||||
# Ruby linting.
|
||||
|
|
|
@ -140,6 +140,7 @@ GEM
|
|||
hashie (3.6.0)
|
||||
health_check (3.0.0)
|
||||
railties (>= 5.0)
|
||||
hiredis (0.6.3)
|
||||
http_accept_language (2.1.1)
|
||||
i18n (1.6.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
|
@ -257,6 +258,7 @@ GEM
|
|||
recaptcha (5.0.0)
|
||||
json
|
||||
redcarpet (3.4.0)
|
||||
redis (4.1.2)
|
||||
remote_syslog_logger (1.0.4)
|
||||
syslog_protocol
|
||||
request_store (1.4.1)
|
||||
|
@ -363,6 +365,7 @@ DEPENDENCIES
|
|||
faker
|
||||
font-awesome-sass (~> 5.9.0)
|
||||
health_check
|
||||
hiredis
|
||||
http_accept_language
|
||||
i18n-language-mapping (~> 0.1.0)
|
||||
jbuilder (~> 2.5)
|
||||
|
@ -385,6 +388,7 @@ DEPENDENCIES
|
|||
random_password
|
||||
recaptcha
|
||||
redcarpet
|
||||
redis
|
||||
remote_syslog_logger
|
||||
rspec-rails (~> 3.7)
|
||||
rubocop
|
||||
|
|
|
@ -16,7 +16,22 @@ Rails.application.configure do
|
|||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
if ENV['REDIS_URL'].present?
|
||||
# Set up Redis cache store
|
||||
config.cache_store = :redis_cache_store, { url: ENV['REDIS_URL'],
|
||||
|
||||
connect_timeout: 30, # Defaults to 20 seconds
|
||||
read_timeout: 0.2, # Defaults to 1 second
|
||||
write_timeout: 0.2, # Defaults to 1 second
|
||||
reconnect_attempts: 1, # Defaults to 0
|
||||
|
||||
error_handler: lambda { |method:, returning:, exception:|
|
||||
config.logger.warn "Support: Redis cache action #{method} failed and returned '#{returning}': #{exception}"
|
||||
} }
|
||||
else
|
||||
config.cache_store = :memory_store
|
||||
end
|
||||
|
||||
config.public_file_server.headers = {
|
||||
'Cache-Control' => "public, max-age=#{1.years.to_i}"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue