index.coffee 669 B

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