lib/twitch/bot/memory/redis.rb in twitch-bot-3.2.1 vs lib/twitch/bot/memory/redis.rb in twitch-bot-4.0.0
- old
+ new
@@ -23,15 +23,18 @@
private
attr_reader :client, :redis
def connect_db
+ url = ENV["REDIS_URL"] || redis_config_url
+ ::Redis.new(url: url)
+ end
+
+ def redis_config_url
config = client.config
- host = config.setting("redis_host") ||
- ENV["REDIS_HOST"] || "localhost"
- port = config.setting("redis_port") ||
- ENV["REDIS_PORT"] || 6379
- ::Redis.new(host: host, port: port)
+ host = config.setting("redis_host") || "localhost"
+ port = config.setting("redis_port") || 6379
+ "redis://#{host}:#{port}"
end
end
end
end
end