mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-24 05:42:12 +00:00
use redis-sharelatex with redis cluster config
This commit is contained in:
parent
df38893538
commit
3045becbb6
4 changed files with 18 additions and 10 deletions
|
@ -1,14 +1,12 @@
|
||||||
Settings = require "settings-sharelatex"
|
Settings = require "settings-sharelatex"
|
||||||
redis = require("redis-sharelatex")
|
redis = require("redis-sharelatex")
|
||||||
rclient = redis.createClient(Settings.redis.web)
|
rclient = redis.createClient(Settings.redis.history)
|
||||||
|
Keys = Settings.redis.history.key_schema
|
||||||
rawUpdatesKey = (doc_id) -> "UncompressedHistoryOps:#{doc_id}"
|
|
||||||
docsWithHistoryOpsKey = (project_id) -> "DocsWithHistoryOps:#{project_id}"
|
|
||||||
|
|
||||||
module.exports = RedisManager =
|
module.exports = RedisManager =
|
||||||
|
|
||||||
getOldestDocUpdates: (doc_id, batchSize, callback = (error, jsonUpdates) ->) ->
|
getOldestDocUpdates: (doc_id, batchSize, callback = (error, jsonUpdates) ->) ->
|
||||||
key = rawUpdatesKey(doc_id)
|
key = Keys.uncompressedHistoryOps({doc_id})
|
||||||
rclient.lrange key, 0, batchSize - 1, callback
|
rclient.lrange key, 0, batchSize - 1, callback
|
||||||
|
|
||||||
expandDocUpdates: (jsonUpdates, callback = (error, rawUpdates) ->) ->
|
expandDocUpdates: (jsonUpdates, callback = (error, rawUpdates) ->) ->
|
||||||
|
@ -22,13 +20,13 @@ module.exports = RedisManager =
|
||||||
multi = rclient.multi()
|
multi = rclient.multi()
|
||||||
# Delete all the updates which have been applied (exact match)
|
# Delete all the updates which have been applied (exact match)
|
||||||
for update in docUpdates or []
|
for update in docUpdates or []
|
||||||
multi.lrem rawUpdatesKey(doc_id), 0, update
|
multi.lrem Keys.uncompressedHistoryOps({doc_id}), 0, update
|
||||||
# It's ok to delete the doc_id from the set here. Even though the list
|
# It's ok to delete the doc_id from the set here. Even though the list
|
||||||
# of updates may not be empty, we will continue to process it until it is.
|
# of updates may not be empty, we will continue to process it until it is.
|
||||||
multi.srem docsWithHistoryOpsKey(project_id), doc_id
|
multi.srem Keys.docsWithHistoryOps({project_id}), doc_id
|
||||||
multi.exec (error, results) ->
|
multi.exec (error, results) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
callback null
|
callback null
|
||||||
|
|
||||||
getDocIdsWithHistoryOps: (project_id, callback = (error, doc_ids) ->) ->
|
getDocIdsWithHistoryOps: (project_id, callback = (error, doc_ids) ->) ->
|
||||||
rclient.smembers docsWithHistoryOpsKey(project_id), callback
|
rclient.smembers Keys.docsWithHistoryOps({project_id}), callback
|
||||||
|
|
|
@ -22,6 +22,13 @@ module.exports =
|
||||||
host: "localhost"
|
host: "localhost"
|
||||||
port: 6379
|
port: 6379
|
||||||
pass: ""
|
pass: ""
|
||||||
|
history:
|
||||||
|
port:"6379"
|
||||||
|
host:"localhost"
|
||||||
|
password:""
|
||||||
|
key_schema:
|
||||||
|
uncompressedHistoryOps: ({doc_id}) -> "UncompressedHistoryOps:#{doc_id}"
|
||||||
|
docsWithHistoryOps: ({project_id}) -> "DocsWithHistoryOps:#{project_id}"
|
||||||
|
|
||||||
trackchanges:
|
trackchanges:
|
||||||
s3:
|
s3:
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.7.1",
|
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.7.1",
|
||||||
"request": "~2.33.0",
|
"request": "~2.33.0",
|
||||||
"requestretry": "^1.12.0",
|
"requestretry": "^1.12.0",
|
||||||
"redis-sharelatex": "~0.0.9",
|
"redis-sharelatex": "git+https://github.com/sharelatex/redis-sharelatex.git#v1.0.0",
|
||||||
"redis": "~0.10.1",
|
"redis": "~0.10.1",
|
||||||
"underscore": "~1.7.0",
|
"underscore": "~1.7.0",
|
||||||
"mongo-uri": "^0.1.2",
|
"mongo-uri": "^0.1.2",
|
||||||
|
|
|
@ -14,7 +14,10 @@ describe "RedisManager", ->
|
||||||
multi: () => @rclient
|
multi: () => @rclient
|
||||||
"settings-sharelatex":
|
"settings-sharelatex":
|
||||||
redis:
|
redis:
|
||||||
web:{}
|
history:
|
||||||
|
key_schema:
|
||||||
|
uncompressedHistoryOps: ({doc_id}) -> "UncompressedHistoryOps:#{doc_id}"
|
||||||
|
docsWithHistoryOps: ({project_id}) -> "DocsWithHistoryOps:#{project_id}"
|
||||||
@doc_id = "doc-id-123"
|
@doc_id = "doc-id-123"
|
||||||
@project_id = "project-id-123"
|
@project_id = "project-id-123"
|
||||||
@batchSize = 100
|
@batchSize = 100
|
||||||
|
|
Loading…
Reference in a new issue