mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
21 lines
640 B
CoffeeScript
21 lines
640 B
CoffeeScript
Settings = require 'settings-sharelatex'
|
|
redis = require 'redis-sharelatex'
|
|
ioredis = require 'ioredis'
|
|
logger = require 'logger-sharelatex'
|
|
|
|
redisSessionsSettings = Settings.redis.websessions or Settings.redis.web
|
|
|
|
module.exports = Redis =
|
|
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
|
|
|
|
sessionSetKey: (user) ->
|
|
if redisSessionsSettings?.cluster?
|
|
return "UserSessions:{#{user._id}}"
|
|
else
|
|
return "UserSessions:#{user._id}"
|