index.coffee 554 B

123456789101112131415161718192021
  1. _ = require("underscore")
  2. module.exports =
  3. createClient: (opts)->
  4. if opts.password?
  5. opts.auth_pass = opts.password
  6. delete opts.password
  7. if opts.endpoints?
  8. standardOpts = _.clone(opts)
  9. delete standardOpts.endpoints
  10. delete standardOpts.masterName
  11. client = require("redis-sentinel").createClient opts.endpoints, opts.masterName, standardOpts
  12. else
  13. standardOpts = _.clone(opts)
  14. delete standardOpts.port
  15. delete standardOpts.host
  16. client = require("redis").createClient opts.port, opts.host, standardOpts
  17. return client