Hey, I've been trying to replicate this caching from one of our v7 sites in a new Umbraco 8 site, however lots has changed and I cant seem to figure it out.
public IList<HelpTopic> HelpTopics
{
get
{
return (IList<HelpTopic>)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(HelpTopicsCacheKey, () =>
{
var umbraco = new UmbracoHelper(UmbracoContext.Current);
var contentAtRoot = umbraco.TypedContentAtRoot();
var container = contentAtRoot.FirstOrDefault(x => x.DocumentTypeAlias == "helpSectionContainer");
var helpTopicContainer = container.Children.FirstOrDefault(x => x.DocumentTypeAlias == "helpTopicContainer") as HelpTopicContainer;
var helpTopics = helpTopicContainer.Children<HelpTopic>();
return helpTopics.ToList();
});
}
}
I am aware that the way that content is fetched there will not work in V8, and that's okay, its this part that's giving me the trouble:
In V8 the application caches: RuntimeCache, RequestCache and IsolatedCache are represented by an AppCaches 'gateway' class.
The example you refer to in the documentation is injecting this AppCaches class into the custom service.
How do you access AppCaches from a template view?
Well it's a property of the UmbracoViewPage<T> class, so as your View/Template inherits UmbracoViewPage you have access to an AppCaches property... (in the same way that you can access Services. to access the core services, or Umbraco. to access the Umbraco Helper methods....
What happens on a Load Balance environment - when the front end URL is different to the Backoffice CMS URL - how can we clear the cache in the CMS and for it to effect the Front end?
Umbraco 8 Runtime Cache
Hey, I've been trying to replicate this caching from one of our v7 sites in a new Umbraco 8 site, however lots has changed and I cant seem to figure it out.
I am aware that the way that content is fetched there will not work in V8, and that's okay, its this part that's giving me the trouble:
I have tried looking at the example here: https://our.umbraco.com/documentation/Reference/Cache/examples/tags however it doesn't seem to help.
I need to be able to call this from a template file.
Any help is appreciated, thank you in advance :)
Hi Liam
In V8 the application caches: RuntimeCache, RequestCache and IsolatedCache are represented by an AppCaches 'gateway' class.
The example you refer to in the documentation is injecting this AppCaches class into the custom service.
How do you access AppCaches from a template view?
Well it's a property of the
UmbracoViewPage<T>
class, so as your View/Template inherits UmbracoViewPage you have access to an AppCaches property... (in the same way that you can access Services. to access the core services, or Umbraco. to access the Umbraco Helper methods....https://github.com/umbraco/Umbraco-CMS/blob/0b6f1f6e117d1cb475230073699c725ea7b2dd4a/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs
So you should be able to use
regards
Marc
What happens on a Load Balance environment - when the front end URL is different to the Backoffice CMS URL - how can we clear the cache in the CMS and for it to effect the Front end?
is working on a reply...