Reputation: 1035
We have set up multple Redis instances in Herkou to handle different caches and queues, how do you set up Rails to use different instances?
Upvotes: 2
Views: 831
Reputation: 398
You can initiate as many redis clients as you want and use the same at different places.
Say something like this,
cache1 = Redis.new(host: 'cache1.redis-server.com', port: 6379)
cache2 = Redis.new(host: 'cache2.redis-server.com', port: 6379)
queues = Redis.new(host: 'queues.redis-server.com', port: 6379)
cache1.set('my_key', 'my_value')
queues.lpush('my_queue', 'my_job')
If you are also using Sidekiq and want a separate connection for it, refer the docs here
Upvotes: 3