I am looking over caching methods in Kentico 13 .net Core. Specically looking at the RepositoryCacheHelper class, and CachePages method.
My current use case is wanting to cache all pages of a given PageType, and invalidate the cache if any of the pages change.
The below works well - List stays cached until I make a change to one of the items (I did a test where I changed value in database, and it didn't update in code as expected).
var otherGroupItems = pageRetriever.Retrieve<NavigationGroup>(
query => query
.WhereEquals(nameof(NavigationGroup.ClassName), NavigationGroup.CLASS_NAME),
cache => cache
.Key($"node|{SiteContext.CurrentSiteName}|{NavigationGroup.CLASS_NAME}|all")
.Dependencies((_, builder) => { }, true)
).ToList();
I then tried doing something similar using RepositoryCacheHelper
var other2 = repositoryCacheHelper.CachePages(() =>
{
var otherGroupItems = pageRetriever.Retrieve<NavigationGroup>(
query => query
.WhereEquals(nameof(NavigationGroup.ClassName), NavigationGroup.CLASS_NAME)).ToList();
return otherGroupItems;
}, $"{nameof(NavigationRepository)}|{nameof(GetMainNavigation)}", new[]
{
$"node|{SiteContext.CurrentSiteName}|{NavigationGroup.CLASS_NAME}|all"
});
When a change in the CMS is made, the cache here is not cleared. I think I must have done something wrong with my dependency keys, but any tips greatly appreciated.