From 3432d9e91ad7768161bc7d586eb326b513150b05 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 26 Nov 2015 15:16:54 +0000 Subject: [PATCH] added comments for redis delete --- services/track-changes/app/coffee/RedisManager.coffee | 5 +++-- services/track-changes/app/coffee/UpdatesManager.coffee | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/services/track-changes/app/coffee/RedisManager.coffee b/services/track-changes/app/coffee/RedisManager.coffee index 6cc0f206be..a634bbfed9 100644 --- a/services/track-changes/app/coffee/RedisManager.coffee +++ b/services/track-changes/app/coffee/RedisManager.coffee @@ -19,11 +19,12 @@ module.exports = RedisManager = callback null, rawUpdates deleteAppliedDocUpdates: (project_id, doc_id, docUpdates, callback = (error) ->) -> - # 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 = rclient.multi() + # Delete all the updates which have been applied (exact match) for update in docUpdates or [] multi.lrem rawUpdatesKey(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.exec (error, results) -> return callback(error) if error? diff --git a/services/track-changes/app/coffee/UpdatesManager.coffee b/services/track-changes/app/coffee/UpdatesManager.coffee index b46e4ccffa..e2b190c804 100644 --- a/services/track-changes/app/coffee/UpdatesManager.coffee +++ b/services/track-changes/app/coffee/UpdatesManager.coffee @@ -59,14 +59,17 @@ module.exports = UpdatesManager = return callback(error) if error? MongoManager.backportProjectId project_id, doc_id, (error) -> return callback(error) if error? + # get the updates as strings from redis (so we can delete them after they are applied) RedisManager.getOldestDocUpdates doc_id, UpdatesManager.REDIS_READ_BATCH_SIZE, (error, docUpdates) -> return callback(error) if error? length = docUpdates.length + # parse the redis strings into ShareJs updates RedisManager.expandDocUpdates docUpdates, (error, rawUpdates) -> return callback(error) if error? UpdatesManager.compressAndSaveRawUpdates project_id, doc_id, rawUpdates, temporary, (error) -> return callback(error) if error? logger.log project_id: project_id, doc_id: doc_id, "compressed and saved doc updates" + # delete the applied updates from redis RedisManager.deleteAppliedDocUpdates project_id, doc_id, docUpdates, (error) -> return callback(error) if error? if length == UpdatesManager.REDIS_READ_BATCH_SIZE