Gab-Social/config/initializers/redis.rb

18 lines
397 B
Ruby
Raw Normal View History

2019-07-02 07:10:25 +00:00
# frozen_string_literal: true
2021-01-14 04:33:49 +00:00
require 'connection_pool'
2019-07-02 07:10:25 +00:00
2021-01-14 04:33:49 +00:00
redis_connection = ConnectionPool::Wrapper.new(size: ENV['REDIS_POOL_SIZE'] || 5, timeout: 10) { Redis.new(
2019-07-02 07:10:25 +00:00
url: ENV['REDIS_URL'],
driver: :hiredis
2021-01-14 04:33:49 +00:00
)}
2019-07-02 07:10:25 +00:00
namespace = ENV.fetch('REDIS_NAMESPACE') { nil }
if namespace
Redis.current = Redis::Namespace.new(namespace, redis: redis_connection)
else
Redis.current = redis_connection
end