Skip to content

Commit

Permalink
Add option to use native Ruby driver for Redis (mastodon#30717)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmstan authored Jun 17, 2024
1 parent d7b7617 commit d5f02ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/lib/redis_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions lib/mastodon/redis_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit d5f02ad

Please sign in to comment.