From 642b0ee2096077843652786373d368084535cd83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Sanguinetti?= Date: Mon, 14 Jan 2019 17:40:49 -0300 Subject: [PATCH] Connect to ENV["REDIS_URL"] by default This makes it so that if you have a `REDIS_URL` environment variable set, redic will connect to that, and if that's not set it will connect to the default `redis://127.0.0.1:6379` address. --- lib/redic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redic.rb b/lib/redic.rb index 29386c3..f741b04 100644 --- a/lib/redic.rb +++ b/lib/redic.rb @@ -4,7 +4,7 @@ class Redic attr :url attr :client - def initialize(url = "redis://127.0.0.1:6379", timeout = 10_000_000) + def initialize(url = ENV.fetch("REDIS_URL", "redis://127.0.0.1:6379"), timeout = 10_000_000) @url = url @client = Redic::Client.new(url, timeout) @buffer = Hash.new { |h, k| h[k] = [] }