Merge pull request #10514 from colinux/redis-timeout

Tech: réduit le connect timeout de redis d'1s à 0.2s
This commit is contained in:
Colin Darie 2024-06-14 11:40:06 +00:00 committed by GitHub
commit 321409eb25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 8 deletions

View file

@ -62,16 +62,20 @@ Rails.application.configure do
# Use a different cache store in production.
if ENV['REDIS_CACHE_URL'].present?
redis_options = { url: ENV['REDIS_CACHE_URL'] }
redis_options[:ssl] = (ENV['REDIS_CACHE_SSL'] == 'enabled')
if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'
redis_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE }
end
redis_options[:error_handler] = -> (method:, returning:, exception:) {
redis_options = {
url: ENV['REDIS_CACHE_URL'],
connect_timeout: 0.2,
error_handler: -> (method:, returning:, exception:) {
Sentry.capture_exception exception, level: 'warning',
tags: { method: method, returning: returning }
}
}
redis_options[:ssl] = ENV['REDIS_CACHE_SSL'] == 'enabled'
if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'
redis_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE }
end
config.cache_store = :redis_cache_store, redis_options
end

View file

@ -1,6 +1,7 @@
redis_shared_options = {
url: ENV['REDIS_CACHE_URL'], # will fallback to default redis url if empty, and won't fail if there is no redis server
ssl: ENV['REDIS_CACHE_SSL'] == 'enabled'
ssl: ENV['REDIS_CACHE_SSL'] == 'enabled',
connect_timeout: 0.2
}
redis_shared_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE } if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'