Skip to content

Commit

Permalink
Merge pull request #2719 from cenit-io/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sanchojaf committed Sep 22, 2019
2 parents f395178 + 61cdc31 commit e83f923
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/cenit/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@ def client?

def client
unless instance_variable_defined?(:@redis_client)
client = ::Redis.new(host: ENV["REDIS_HOST"], port: 6379, db: 15)
client =
if (redis_url = ENV['REDIS_URL'])
# specify a connection option as a redis:// URL
# e.g "redis://:p4ssw0rd@10.0.1.1:6380/15"
::Redis.new(url: redis_url)
else
# Defauls values similar to the redis gem
# https://github.com/redis/redis-rb/blob/master/lib/redis/client.rb#L10-L26
redis_host = ENV['REDIS_HOST'] || '127.0.0.1'
redis_port = (ENV['REDIS_PORT'] || 6379).to_i
redis_db = (ENV['REDIS_DB'] || 0).to_i
redis_password = ENV['REDIS_PASSWORD'] || nil

::Redis.new(host: redis_host, port: redis_port, db: redis_db, password: redis_password)
end
client =
begin
client.ping
Expand Down

0 comments on commit e83f923

Please sign in to comment.