chore: Use connection_pool for redis (#5790)

fixes: #3199
This commit is contained in:
Sojan Jose
2022-11-02 17:31:20 -07:00
committed by GitHub
parent 936c2ec7e2
commit 8b659de73d
5 changed files with 30 additions and 27 deletions

View File

@@ -2,15 +2,15 @@ Rails.application.reloader.to_prepare do
# Alfred
# Add here as you use it for more features
# Used for Round Robin, Conversation Emails & Online Presence
$alfred = ConnectionPool::Wrapper.new(size: 5, timeout: 3) do
$alfred = ConnectionPool.new(size: 5, timeout: 3) do
redis = Rails.env.test? ? MockRedis.new : Redis.new(Redis::Config.app)
Redis::Namespace.new('alfred', redis: redis, warning: true)
end
# Velma : Determined protector
# used in rack attack
$velma = ConnectionPool::Wrapper.new(size: 5, timeout: 3) do
redis = Rails.env.test? ? MockRedis.new : Redis.new(Redis::Config.app)
Redis::Namespace.new('velma', redis: redis, warning: true)
$velma = ConnectionPool.new(size: 5, timeout: 3) do
config = Rails.env.test? ? MockRedis.new : Redis.new(Redis::Config.app)
Redis::Namespace.new('velma', redis: config, warning: true)
end
end

View File

@@ -11,7 +11,7 @@ class Rack::Attack
# Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
# https://github.com/rack/rack-attack/issues/102
Rack::Attack.cache.store = Rack::Attack::StoreProxy::RedisProxy.new($velma)
Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new(redis: $velma)
class Request < ::Rack::Request
# You many need to specify a method to fetch the correct remote IP address