added comments for redis delete

This commit is contained in:
Brian Gough 2015-11-26 15:16:54 +00:00
parent e65549099c
commit 3432d9e91a
2 changed files with 6 additions and 2 deletions

View file

@ -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?

View file

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