mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
update redis key
This commit is contained in:
parent
0939a558d7
commit
a07e516f65
2 changed files with 10 additions and 8 deletions
|
@ -5,15 +5,15 @@ settings =
|
|||
port: process.env['REAL_TIME_REDIS_PORT'] or process.env['REDIS_PORT'] or "6379"
|
||||
password: process.env["REAL_TIME_REDIS_PASSWORD"] or process.env["REDIS_PASSWORD"] or ""
|
||||
key_schema:
|
||||
clientsInProject: ({project_id}) -> "clients_in_project:#{project_id}"
|
||||
connectedUser: ({project_id, client_id})-> "connected_user:#{project_id}:#{client_id}"
|
||||
clientsInProject: ({project_id}) -> "clients_in_project:{#{project_id}}"
|
||||
connectedUser: ({project_id, client_id})-> "connected_user:{#{project_id}}:#{client_id}"
|
||||
|
||||
documentupdater:
|
||||
host: process.env['DOC_UPDATER_REDIS_HOST'] or process.env['REDIS_HOST'] or "localhost"
|
||||
port: process.env['DOC_UPDATER_REDIS_PORT'] or process.env['REDIS_PORT'] or "6379"
|
||||
password: process.env["DOC_UPDATER_REDIS_PASSWORD"] or process.env["REDIS_PASSWORD"] or ""
|
||||
key_schema:
|
||||
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
||||
pendingUpdates: ({doc_id}) -> "PendingUpdates:{#{doc_id}}"
|
||||
|
||||
websessions:
|
||||
host: process.env['WEB_REDIS_HOST'] or process.env['REDIS_HOST'] or "localhost"
|
||||
|
|
|
@ -10,6 +10,8 @@ settings = require "settings-sharelatex"
|
|||
redis = require "redis-sharelatex"
|
||||
rclient = redis.createClient(settings.redis.websessions)
|
||||
|
||||
redisSettings = settings.redis
|
||||
|
||||
describe "applyOtUpdate", ->
|
||||
before ->
|
||||
@update = {
|
||||
|
@ -48,7 +50,7 @@ describe "applyOtUpdate", ->
|
|||
done()
|
||||
|
||||
it "should push the update into redis", (done) ->
|
||||
rclient.lrange "PendingUpdates:#{@doc_id}", 0, -1, (error, [update]) =>
|
||||
rclient.lrange redisSettings.documentupdater.key_schema.pendingUpdates({@doc_id}), 0, -1, (error, [update]) =>
|
||||
update = JSON.parse(update)
|
||||
update.op.should.deep.equal @update.op
|
||||
update.meta.should.deep.equal {
|
||||
|
@ -61,7 +63,7 @@ describe "applyOtUpdate", ->
|
|||
async.series [
|
||||
(cb) => rclient.del "pending-updates-list", cb
|
||||
(cb) => rclient.del "DocsWithPendingUpdates", "#{@project_id}:#{@doc_id}", cb
|
||||
(cb) => rclient.del "PendingUpdates:#{@doc_id}", cb
|
||||
(cb) => rclient.del redisSettings.documentupdater.key_schema.pendingUpdates(@doc_id), cb
|
||||
], done
|
||||
|
||||
describe "when authorized to read-only with an edit update", ->
|
||||
|
@ -102,7 +104,7 @@ describe "applyOtUpdate", ->
|
|||
, 300
|
||||
|
||||
it "should not put the update in redis", (done) ->
|
||||
rclient.llen "PendingUpdates:#{@doc_id}", (error, len) =>
|
||||
rclient.llen redisSettings.documentupdater.key_schema.pendingUpdates({@doc_id}), (error, len) =>
|
||||
len.should.equal 0
|
||||
done()
|
||||
|
||||
|
@ -142,7 +144,7 @@ describe "applyOtUpdate", ->
|
|||
done()
|
||||
|
||||
it "should push the update into redis", (done) ->
|
||||
rclient.lrange "PendingUpdates:#{@doc_id}", 0, -1, (error, [update]) =>
|
||||
rclient.lrange redisSettings.documentupdater.key_schema.pendingUpdates({@doc_id}), 0, -1, (error, [update]) =>
|
||||
update = JSON.parse(update)
|
||||
update.op.should.deep.equal @comment_update.op
|
||||
update.meta.should.deep.equal {
|
||||
|
@ -155,5 +157,5 @@ describe "applyOtUpdate", ->
|
|||
async.series [
|
||||
(cb) => rclient.del "pending-updates-list", cb
|
||||
(cb) => rclient.del "DocsWithPendingUpdates", "#{@project_id}:#{@doc_id}", cb
|
||||
(cb) => rclient.del "PendingUpdates:#{@doc_id}", cb
|
||||
(cb) => rclient.del redisSettings.documentupdater.key_schema.pendingUpdates({@doc_id}), cb
|
||||
], done
|
Loading…
Reference in a new issue