是否有任何方法告诉RavenDb对某些DocumentStore或DocumentSession的所有查询使用WaitForNonStaleResults模式?

最佳答案

您可以在DocumentStore或Session级别使用DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites

文档商店:

IDocumentStore store = new DocumentStore {
    Url = "http://127.0.0.1:8080",
    DefaultDatabase = "DBNAME",
    Conventions = {
        DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites
    }
}.Initialize();

session :

session.Advanced.Conventions.DefaultQueryingConsistency =
    ConsistencyOptions.QueryYourWrites;

请记住,此机制不适用于Map-Reduce索引

您可以在下面查看有关此问题的Matt's评论

09-26 03:36