Skip to content

Commit

Permalink
Cleaning up redis code
Browse files Browse the repository at this point in the history
  • Loading branch information
winton committed Aug 30, 2011
1 parent f5d4dd6 commit 9148756
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/gem_template/boot/redis.rb
@@ -1,22 +1,21 @@
require 'uri'
require 'redis'

def redis
$redis ||= (

env = ENV['RACK_ENV'] || 'development'
yaml = YAML.load(File.read('config/redis.yml'))[env]

db = yaml.keys.first
config = yaml[db]
config['db'] = db

$redis_url = "#{config['host']}:#{config['port']}/#{config['db']}"
url = URI("redis://#{$redis_url}")

::Redis.new(
:host => url.host,
:port => url.port,
:db => url.path[1..-1],
:password => url.password
:host => config['host'],
:port => config['port'],
:db => config['db']
)
)
end
Expand Down

0 comments on commit 9148756

Please sign in to comment.