每个DocumentStore的WaitForNonStaleResults

时间:2011-12-18 20:42:02

标签: .net nosql ravendb

有没有办法告诉RavenDb对某些DocumentStore或DocumentSession的所有查询使用WaitForNonStaleResults模式?

1 个答案:

答案 0 :(得分:10)

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

<强> DocumentStore:

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

<强>会话

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

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

您可以在下面检查Matt's对此问题的评论