在我的集成测试设置中,实体是使用 API 端点创建的,然后该数据立即被其他端点使用。
当索引不是最新的并且获取刚刚写入的项目返回空时,这会产生问题。
如果不将
.Customize(x => x.WaitForNonStaleResults(TimeSpan.FromSeconds(5)))
添加到每个查询中,我可以在全局配置 IDocumentStore
时做一些事情来强制每个查询等待索引完成写入吗?
我找到了一个旧的answer,但该代码对当前版本无效。
在文档存储上使用此约定:
即:
using var store = new DocumentStore
{
Database = database,
Urls = new[] { server.WebUrl },
Conventions = new DocumentConventions { WaitForNonStaleResultsTimeout = TimeSpan.FromSeconds(25) }
}.Initialize();