We have trouble with the caching of our contacts when we query a list of items.
Once we update one of the page type items the cache doesn't invalidate.
As far as I understand it, I need a special dependency for the items in that path, but I didn't had success in building that dependency.
I hope some one is able to help.
Big thanks in advancepublic async Task@IEnumerable@ContactModel@@ GetContactsAsync(string path, IEnumerable@string@ authors)
{
var builder = new CacheDependencyKeysBuilder(_siteRepository, _cacheDependenciesStore);
path = path.TrimEndForPath();
builder.PagePath(path, PathTypeEnum.Children);
var retriever = await _pageRetriever.RetrieveAsync@Contact@(
query =@
{
query
.TopN(10)
.PathForChildren(path)
.Columns(new string[] {
nameof(Contact.Image),
nameof(Contact.Text),
nameof(Contact.Email),
nameof(Contact.Phone),
nameof(Contact.Gender),
})
.OrderBy(nameof(Contact.NodeLevel), nameof(Contact.NodeOrder));
if (authors.Any())
query.WhereIn(nameof(Contact.DocumentName), authors.ToList());
}, cacheSettings =@ cacheSettings
.Dependencies((items, csbuilder) =@ builder.ApplyDependenciesTo(key =@ csbuilder.Custom(key)))
.Key($@GetContactsAsync|{path}|{string.Join(@,@, authors ?? Array.Empty@string@())}@)
.Expiration(TimeSpan.FromMinutes(60))
);
return retriever.Select(x =@ _mapper.Map@ContactModel@(x));
}
↧