diff --git a/app/lib/redis_configuration.rb b/app/lib/redis_configuration.rb index f0e86d985b8a9a..fb1249640fd733 100644 --- a/app/lib/redis_configuration.rb +++ b/app/lib/redis_configuration.rb @@ -42,9 +42,13 @@ def url ENV['REDIS_URL'] end + def redis_driver + ENV.fetch('REDIS_DRIVER', 'hiredis') == 'ruby' ? :ruby : :hiredis + end + private def raw_connection - Redis.new(url: url, driver: :hiredis) + Redis.new(url: url, driver: redis_driver) end end diff --git a/lib/mastodon/redis_config.rb b/lib/mastodon/redis_config.rb index 10672a53587b42..c858b61a053682 100644 --- a/lib/mastodon/redis_config.rb +++ b/lib/mastodon/redis_config.rb @@ -30,8 +30,10 @@ def setup_redis_env_url(prefix = nil, defaults = true) cache_namespace = namespace ? "#{namespace}_cache" : 'cache' sidekiq_namespace = namespace +redis_driver = ENV.fetch('REDIS_DRIVER', 'hiredis') == 'ruby' ? :ruby : :hiredis + REDIS_CACHE_PARAMS = { - driver: :hiredis, + driver: redis_driver, url: ENV['CACHE_REDIS_URL'], expires_in: 10.minutes, namespace: "#{cache_namespace}:7.1", @@ -43,7 +45,7 @@ def setup_redis_env_url(prefix = nil, defaults = true) }.freeze REDIS_SIDEKIQ_PARAMS = { - driver: :hiredis, + driver: redis_driver, url: ENV['SIDEKIQ_REDIS_URL'], namespace: sidekiq_namespace, }.freeze