demarches-normaliennes/config/initializers/kredis.rb
Colin Darie f504e7968d chore(redis): reduce connect timeout from 1s to 0.2s
Prevent web workers from being stalled when Redis is down.
2024-06-12 19:31:50 +02:00

8 lines
429 B
Ruby

redis_volatile_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',
connect_timeout: 0.2
}
redis_volatile_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE } if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'
Kredis::Connections.connections[:volatile] = Redis.new(redis_volatile_options)