Related Content
Tags
Content Definition
Modules
Web Content Management

Agility Dependency Cache

Posted by Russ Huntington on October 24, 2011
0 people like this tutorial
Rate:

The Agility Dependency Cache is designed to help improve performance by allowing you to cache Agility content and set a dependency on the content itself. This means that the cache will get reset when the content is changed, either by an edit or a new item.

An additional feature of the AgilityDependencyCache is that the content will be cached in the HttpContent.Cache only if the website is in “Live” mode. If the website is in development or preview mode the content will be cached in the HttpContent.Items.

The code snipped below illustrates a utility method that will allow you to get a DataView from any content reference name - some of the code should look familiar.

public DataView GetDataView(string contentReferenceName)
{
    // Check the cache to see if we already have an item added
    string cacheKey = string.Format("AgilityContent.{0}", contentReferenceName);
    DataView dataView = (DataView)Agility.Web.Utils.AgilityDependencyCache.Select(cacheKey);  

    if (dataView == null)
    {
        // Nothing found in the cache, get the content from the Agility data store in the usual way
        dataView = Data.GetContentView(contentReferenceName);

        // Add the data into the cache ready for next time we want to access it
        Agility.Web.Utils.AgilityDependencyCache.Insert(cacheKey, dataView, new List { contentReferenceName }, DateTime.Now.AddHours(1));
    }

    return dataView;
}

Add a Comment

   
  
 
 
   
Submit

LOGIN

Log in with your Agility username and password or
register for the site




Log In

REGISTER












Register

FORGOT PASSWORD