Sitefinity Cache

January 07, 2014
Here's how to leverage the Sitefinity Cache Manager in your projects...super easy!

How to add the Cache Manager
public virtual ICacheManager Cache
        return SystemManager.GetCacheManager(CacheManagerInstance.Global);

How to query the Cache
public XDocument GetXmlDocument(){
    XDocument doc = null;
    string cacheKey = "MycacheKey";
    if (this.Cache.Contains(cacheKey))
        //Return the cached object
        return (this.Cache.GetData(cacheKey)) as XDocument;
        //Populate the object
        doc = this.GetXmlData();
        //Add object to the cache
                    new Telerik.Microsoft.Practices.EnterpriseLibrary.Caching.Expirations.AbsoluteTime(TimeSpan.FromMinutes(this.CacheTimeoutMinutes)));
        //Return the object
        return doc;

So there's clearly also methods to remove items from the cache as well, just as easy

Credit: Elena Ganeva @ telerik

Image Description

Steve McNiven-Scott

Best\Only Blogger on this site. Therefore defacto blogger of the year Award Winner.