private <T extends Document> void applyToCache(@Nonnull Collection<T> collection,
@Nullable T oldDoc,
@Nonnull UpdateOp updateOp) {
// cache the new document
if (collection == Collection.NODES) {
CacheValue key = new StringValue(updateOp.getId());
NodeDocument newDoc = (NodeDocument) collection.newDocument(this);
if (oldDoc != null) {
// we can only update the cache based on the oldDoc if we
// still have the oldDoc in the cache, otherwise we may
// update the cache with an outdated document