刚刚找到了一个与 RavenDB 中缓存的方面查询相关的错误。
我找到了设置积极缓存但仅针对给定会话的代码行。在此会话中,代码似乎只获取了一个“FacetSetup”文档,而不是对构面执行查询。但是,我已经确认,当给定的代码行被注释掉时,我会收到当前的方面计数,当我恢复注释并进行更新时,我会收到过时的方面计数。
我的问题是:这条线实际上告诉 Raven 缓存什么?
/// <summary>
/// Gets all the facet names from the main facet document.
/// That way, we know all the possible facets to query over.
/// We will execute a facet query for each facet in the FacetSetup
/// </summary>
private IEnumerable<string> GetFacetNamesFromFacetSetup(IDocumentStore store, string facetDocumentName)
{
IList<string> facetFromDocument = new List<string>();
using (IDocumentSession docSession = store.OpenSession())
{
//The line below here!!
docSession.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(30));
FacetSetup facetSetup = docSession.Load<FacetSetup>(facetDocumentName);
foreach (Facet facet in facetSetup.Facets)
{
facetFromDocument.Add(facet.Name);
}
}
return facetFromDocument;
}