mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-24 02:41:16 +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"
|
||||
redis = require("redis-sharelatex")
|
||||
rclient = redis.createClient(Settings.redis.web)
|
||||
|
||||
rawUpdatesKey = (doc_id) -> "UncompressedHistoryOps:#{doc_id}"
|
||||
docsWithHistoryOpsKey = (project_id) -> "DocsWithHistoryOps:#{project_id}"
|
||||
rclient = redis.createClient(Settings.redis.history)
|
||||
Keys = Settings.redis.history.key_schema
|
||||
|
||||
module.exports = RedisManager =
|
||||
|
||||
getOldestDocUpdates: (doc_id, batchSize, callback = (error, jsonUpdates) ->) ->
|
||||
key = rawUpdatesKey(doc_id)
|
||||
key = Keys.uncompressedHistoryOps({doc_id})
|
||||
rclient.lrange key, 0, batchSize - 1, callback
|
||||
|
||||
expandDocUpdates: (jsonUpdates, callback = (error, rawUpdates) ->) ->
|
||||
|
@ -22,13 +20,13 @@ module.exports = RedisManager =
|
|||
multi = rclient.multi()
|
||||
# Delete all the updates which have been applied (exact match)
|
||||
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
|
||||
# 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) ->
|
||||
return callback(error) if error?
|
||||
callback null
|
||||
|
||||
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"
|
||||
port: 6379
|
||||
pass: ""
|
||||
history:
|
||||
port:"6379"
|
||||
host:"localhost"
|
||||
password:""
|
||||
key_schema:
|
||||
uncompressedHistoryOps: ({doc_id}) -> "UncompressedHistoryOps:#{doc_id}"
|
||||
docsWithHistoryOps: ({project_id}) -> "DocsWithHistoryOps:#{project_id}"
|
||||
|
||||
trackchanges:
|
||||
s3:
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.7.1",
|
||||
"request": "~2.33.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",
|
||||
"underscore": "~1.7.0",
|
||||
"mongo-uri": "^0.1.2",
|
||||
|
|
|
@ -14,7 +14,10 @@ describe "RedisManager", ->
|
|||
multi: () => @rclient
|
||||
"settings-sharelatex":
|
||||
redis:
|
||||
web:{}
|
||||
history:
|
||||
key_schema:
|
||||
uncompressedHistoryOps: ({doc_id}) -> "UncompressedHistoryOps:#{doc_id}"
|
||||
docsWithHistoryOps: ({project_id}) -> "DocsWithHistoryOps:#{project_id}"
|
||||
@doc_id = "doc-id-123"
|
||||
@project_id = "project-id-123"
|
||||
@batchSize = 100
|
||||
|
|
Loading…
Reference in a new issue