|
@@ -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)
|
|
|
|
|
-
|
|
|
|
|
-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 =
|
|
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
|