fixed a potential bug, when adding a document, cache must either be updated or invalidated.