AggressivelyCacheFor is global for the document store. And it returns an IDisposable. Until you dispose it, all operations will be eagerly cached.
Caching Facet Queries
-
29-06-2022 - |
Question
Just tracked down a bug relating to what appears to be a facet query being cached in RavenDB.
I found the line of code that sets aggresive caching but only for the given session. In this session, it appears the code is only getting a 'FacetSetup' doc and not executing a query on facets. However, I have confirmed that when the given line of code is commented out, I receive the current facet count and when I reinstate the comment and make an update, I receive the stale facet count.
My question is: What does this line actually tell Raven to cache?
/// <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;
}
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow