2

I am using RavenDB 3.5. I know that querying entities is not acid but loading per ID is. Apparently writing to DB is also acid. So far so good. Now a question: I've found some code:

  session.Advanced.WaitForIndexesAfterSaveChanges();
                entity = session.Load<T>(id);
                session.Delete(entity);
                session.SaveChanges();
                // Func<T, T> command
                command?.Invoke(entity);

what would be the purpose of calling WaitForIndexesAfterSaveChanges() here? is this because of executing a command? or is it rather because might depedning/consuming queries are supposed to immediately catch up with those changes made? if this would be the case, I could remove WaitForIndexesAfterSaveChanges() in this code block and just add WaitForNonStaleResultsAsOfNow() in the queries, couldn't I? When would I use WaitForIndexesAfterSaveChanges() in the first place if my critical queries are already flagged with WaitForNonStaleResultsAsOfNow()?

yBother
  • 648
  • 6
  • 25

1 Answers1

0

The most likely reason for this behavior is wanting to wait, in this operation, for the indexes to complete. A good example why you want to do that is when you create a new item, and the next operation is going to show a list of items. You can use WaitForIndexesAfterSaveChanges to wait, during the save, for the indexes to update.

Ayende Rahien
  • 22,925
  • 1
  • 36
  • 41