AI OnAI Off
PageDataCollection theDataSource;
theDataSource = CacheManager.Get("MyMenuDataSource");
if (theDataSource == null) // Was not in cache
{
//Fetch the data from somewhere
theDataSource = GetMyPagesSomeHow();
CacheManager.Add("MyMenuDataSource"
,theDataSource
,System.Web.Caching.CacheItemPriority.Normal);
}
myTreeControl.DataSource = theDataSource;
myTreeControl.DataBind();
The above code is from memory and untested, but with some tweaking it should work. By using EPiServer cache manager instead of accessing the ASP.NET cache directly you keep support for cache-invalidation on cluster configurations.
But as EPiServer aleady caches page data in its DataFactory class I suspect you won't gain much by caching the data source. Propably it's the creation of the HTML for the three itself that takes time. But I thought that the HTML output cache would take care of that. You have output caching enabled?