cache: Fix thread-safety of debug commits
cache: Fix thread-safety of debug commits

They were placed in such a manner to cause dead locks. Now they are
moved above lock acquistion.

fengzhyuan/visionworkbench,AveRapina/visionworkbench,fengzhyuan/visionworkbench,AveRapina/visionworkbench,AveRapina/visionworkbench,AveRapina/visionworkbench,AveRapina/visionworkbench,fengzhyuan/visionworkbench,DougFirErickson/visionworkbench,DougFirErickson/visionworkbench,fengzhyuan/visionworkbench,DougFirErickson/visionworkbench,AveRapina/visionworkbench,DougFirErickson/visionworkbench,DougFirErickson/visionworkbench,fengzhyuan/visionworkbench,DougFirErickson/visionworkbench,fengzhyuan/visionworkbench,fengzhyuan/visionworkbench