Refactor Sidekiq settings and set expiry in development

This means old cache entries will be automatically removed instead of perpetually filling up the local Redis instance in dev.
This commit is contained in:
Matt-Yorkley
2021-06-09 18:19:58 +01:00
parent 5a06ba651a
commit 083f512aae

View File

@@ -1,9 +1,15 @@
redis_jobs_url = ENV.fetch("OFN_REDIS_JOBS_URL", "redis://localhost:6381/0")
# Redis connection configuration for Sidekiq
redis_connection_settings = {
url: ENV.fetch("OFN_REDIS_JOBS_URL", "redis://localhost:6381/0"),
network_timeout: 5,
expires_in: Rails.env.development? ? 90.minutes : nil
}
Sidekiq.configure_server do |config|
config.redis = { url: redis_jobs_url, network_timeout: 5 }
config.redis = redis_connection_settings
end
Sidekiq.configure_client do |config|
config.redis = { url: redis_jobs_url, network_timeout: 5 }
config.redis = redis_connection_settings
end