Set readthis connection pool after configuring cache_store as readthis_store?
Closed this issue · 3 comments
If I configure this in my config/production.rb
config.cache_store = :readthis_store, {
expires_in: 30.seconds.to_i,
namespace: 'cache',
redis: { url: ENV.fetch('REDIS_URL'), driver: :hiredis }
}
How can I set it's connection pool later when my puma workers call on_worker_boot
on_worker_boot is called after config/production.rb
The pool for readthis cannot be passed in via options
https://github.com/sorentwo/readthis/blob/master/lib/readthis/cache.rb#L59
I am stuck. Before I start hacking and making a mess I thought I'd ask here if I'm on the right track?
https://devcenter.heroku.com/articles/concurrency-and-database-connections#threaded-servers
I was thinking of a change like this
https://github.com/holmansv/readthis/commit/2698143da9620e6c1c0a9884dd8f332649703052
But I'm not sure how ReadThis gets initialized when set as Rails cache_store, and how to set this after bootup?
The pool's connections are established lazily and will be automatically reconnected after forking.
I've written a bit about how it is undesirable to explicitly re-establish the pool after forking: http://sorentwo.com/2015/08/25/managing-redis-reconnections-from-ruby.html
So, good news, you don't need to do anything =)