Sitefinity Cache

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
Did you like this post, did I help you out, are you feeling generous

  Buy me a beer