2016-11-08 10:32:36 -05:00
|
|
|
Settings = require 'settings-sharelatex'
|
|
|
|
redis = require 'redis-sharelatex'
|
|
|
|
ioredis = require 'ioredis'
|
|
|
|
logger = require 'logger-sharelatex'
|
|
|
|
|
2016-11-10 09:31:48 -05:00
|
|
|
redisSessionsSettings = Settings.redis.websessions or Settings.redis.web
|
2016-11-08 10:32:36 -05:00
|
|
|
|
2016-11-10 09:31:48 -05:00
|
|
|
module.exports = Redis =
|
2016-11-08 10:32:36 -05:00
|
|
|
client: () ->
|
|
|
|
if redisSessionsSettings?.cluster?
|
|
|
|
logger.log {}, "using redis cluster for web sessions"
|
|
|
|
rclient = new ioredis.Cluster(redisSessionsSettings.cluster)
|
|
|
|
else
|
|
|
|
rclient = redis.createClient(redisSessionsSettings)
|
|
|
|
return rclient
|
2016-11-10 09:31:48 -05:00
|
|
|
|
|
|
|
sessionSetKey: (user) ->
|
|
|
|
if redisSessionsSettings?.cluster?
|
|
|
|
return "UserSessions:{#{user._id}}"
|
|
|
|
else
|
|
|
|
return "UserSessions:#{user._id}"
|