2014-09-26 09:46:23 -04:00
|
|
|
_ = require("underscore")
|
|
|
|
|
2014-09-25 12:33:27 -04:00
|
|
|
module.exports =
|
|
|
|
|
2014-09-26 09:46:23 -04:00
|
|
|
createClient: (opts)->
|
2014-09-29 06:40:40 -04:00
|
|
|
if opts.password?
|
|
|
|
opts.auth_pass = opts.password
|
|
|
|
delete opts.password
|
2014-09-26 09:46:23 -04:00
|
|
|
if opts.endpoints?
|
|
|
|
standardOpts = _.clone(opts)
|
|
|
|
delete standardOpts.endpoints
|
|
|
|
delete standardOpts.masterName
|
|
|
|
client = require("redis-sentinel").createClient opts.endpoints, opts.masterName, standardOpts
|
2014-09-25 12:33:27 -04:00
|
|
|
else
|
2014-09-26 09:46:23 -04:00
|
|
|
standardOpts = _.clone(opts)
|
|
|
|
delete standardOpts.port
|
|
|
|
delete standardOpts.host
|
|
|
|
client = require("redis").createClient opts.port, opts.host, standardOpts
|
2014-09-25 12:33:27 -04:00
|
|
|
return client
|
|
|
|
|
|
|
|
|