lib/sad/config.rb in sad-1.0.0 vs lib/sad/config.rb in sad-1.1.0
- old
+ new
@@ -7,20 +7,28 @@
def namespace
@_namespace || 'SadQueue'
end
- def redis=(opts={})
+ def default_rds_opts(inopts={})
opts = {
:host => 'localhost',
:port => 6379,
:db => 0
- }.update opts
- @_redis = EM::Protocols::Redis.connect :host => opts[:host], :port => opts[:port], :db => opts[:db]
+ }.update inopts.dup
+ if opts[:password]
+ url = "redis://#{opts[:password]}@#{opts[:host]}:#{opts[:port]}/#{opts[:db]}"
+ else
+ url = "redis://#{opts[:host]}:#{opts[:port]}/#{opts[:db]}"
+ end
end
+ def redis=(opts={})
+ @_redis = EM::Hiredis.connect default_rds_opts(opts)
+ end
+
def redis
- @_redis || (EM::Protocols::Redis.connect)
+ @_redis || EM::Hiredis.connect
end
end
end
end
\ No newline at end of file