Use
MaintainCache( ParentCollection, 'parentCacheField', Child, 'childParentRelationField', function( doc ){ return calcDocValue(doc); } )
Document value calculation
The last argument calculates the value of a document. Should be a pure function, in other words, it should change any state.
How it works
On insert it calculates the value of the document and increments the parent cache. On update it removes the old value from the old parent, and adds the new value to the new parent (not optimized yet). On remove it decrements the old value from the parent cache.