Closed ViTVetal closed 5 years ago
Readthis already uses connection_pool
to manage a pool of redis connections. You can access to the pool directly, as documented in the README:
Rails.cache.pool.with do |conn|
conn.geoadd($DRIVER_LOCATIONS, latitude, longitude, id)
end
You can configure the pool_size
and the pool_timeout
directly in your cache_store
setup:
config.cache_store = :readthis_store, {
expires_in: 1.minutes.to_i,
namespace: 'cache',
pool_size: 10,
redis: { url: 'redis://localhost:6379/15', driver: :hiredis }
}
@sorentwo So there is no matter that I also use Redis in application for non cache related things (geoadd
etc) and Redis will use same db for cache and for other things (as you can see for pool I used db №15 and for cache №1). Right?
No, so long as all of the data is ephemeral there isn't any problem with doing that. I've written about this a bit in the past: https://sorentwo.com/2015/07/27/optimizing-redis-usage-for-caching.html
@sorentwo Thanks! But in Rails 5+ applications Action Cable uses Redis as adapter for production:
#config/cable.yml
development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: app_production
Is there any way to provide the pool?
Hello! I want to use readthis_store on multithreading Puma. I use Redis in application and for the cache. I use connection_pool more
Should I use same connection pool for cache and if yes how can I do it?