I am using Sidekiq for the first time in a Rails app. This is also my first time using Redis.
I have seen several examples (Here, here, here) where initializers/sidekiq.rb
contains the following lines:
Sidekiq.configure_server do |config|
config.redis = { url: 'redis://localhost:6379/0', namespace: "sidekiq_app_name_#{Rails.env}" }
end
Sidekiq.configure_client do |config|
config.redis = { url: 'redis://localhost:6379/0', namespace: "sidekiq_app_name_#{Rails.env}" }
end
I haven't yet been able to find any documentation explaining exactly what is going on here.
I understand that a hash is being assigned to config.redis
. The hash has a url pointing to the redis server, and a namespace prefixed with sidekiq_app_name_
followed by the current environment. I assume the prefix can be any string of my choosing -- most probably the app of my app.
What I don't understand is, why is the line repeated?
Why is the line repeated?
It's exactly the same. Surely Rails.env
returns the same thing on each occasion? Is it a typo or does the duplication have an effect? If so, what is the point of the duplication?