We are interested in using a distributed cache (Redis) for our Xperience 13 MVC site. The site will be hosted in a web farm on Azure (geo-replicated) so in-memory caching is not an optimal solution. We like the Kentico API and the integration with IPageCacheBuilder because of the ability to invalidate the cache when a dependency is changed on the admin site. We would like to leverage the IPageCacheBuilder in a way that the cached pages will be saved directly on Redis rather than in memory. In other words, we want the following code to cache the result in Redis:
return pageRetriever.Retrieve<Blog>( query => query .Path(nodeAliasPath, PathTypeEnum.Children) .TopN(count) .Culture(culture) .OrderByDescending("BlogDate"), cache => cache .Key($"{nameof(BlogRepository)}|{nameof(GetBlogs)}|{nodeAliasPath}|{count}|{culture}") .Dependencies((_, builder) => builder.PagePath(nodeAliasPath, PathTypeEnum.Children)));
Is that possible at all? What's the best way to have the result cached in a distributed cache without haveing to manage 2 sets of cache: in-memory and distributed?
@Noam,
The IPageRetriever uses IProgressiveCache internally to do caching.
IPageRetriever
You can re-implement this type and override Xperience's DI registration with your 'Redis' implementation of the CMS.Helpers.IProgressive cache interface.
CMS.Helpers.IProgressive
Please, sign in to be able to submit a new answer.