diff --git a/services/track-changes/app/coffee/RedisManager.coffee b/services/track-changes/app/coffee/RedisManager.coffee index a634bbfed9..70cea0805e 100644 --- a/services/track-changes/app/coffee/RedisManager.coffee +++ b/services/track-changes/app/coffee/RedisManager.coffee @@ -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 diff --git a/services/track-changes/config/settings.defaults.coffee b/services/track-changes/config/settings.defaults.coffee index 749887f4da..084ce7de62 100755 --- a/services/track-changes/config/settings.defaults.coffee +++ b/services/track-changes/config/settings.defaults.coffee @@ -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: diff --git a/services/track-changes/package.json b/services/track-changes/package.json index b87967110c..165178b418 100644 --- a/services/track-changes/package.json +++ b/services/track-changes/package.json @@ -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", diff --git a/services/track-changes/test/unit/coffee/RedisManager/RedisManagerTests.coffee b/services/track-changes/test/unit/coffee/RedisManager/RedisManagerTests.coffee index 12f78fd4aa..be20b38d21 100644 --- a/services/track-changes/test/unit/coffee/RedisManager/RedisManagerTests.coffee +++ b/services/track-changes/test/unit/coffee/RedisManager/RedisManagerTests.coffee @@ -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