Przeglądaj źródła

added comments for redis delete

Brian Gough 11 lat temu
rodzic
commit
3432d9e91a

+ 3 - 2
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?

+ 3 - 0
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