redis / redis-rb

A Ruby client library for Redis
MIT License
3.96k stars 1.03k forks source link

Support Redis.default_configuration = { ... } #1288

Closed sebyx07 closed 4 weeks ago

sebyx07 commented 4 weeks ago

problem: I have a rails app + sidekiq + anycable + rails cache. And i want all of them to use redis with hiredis + a different db

solution:

redis_uri = URI.parse(ENV["REDIS_URL"])

Redis.default_configuration = { 
  host: redis_uri.host, port: port = redis_uri.port, driver: :hiredis
}

# for example sidekiq

Sidekiq.configure_server do |c|
  c.redis = { db: 0 }
end
byroot commented 4 weeks ago

I feel this is just as easily done with a simple hash merge in your app. Not really convinced of the usefulness of this.