To implement the native ASP.NET cache is really simple (at least for what we needed). We use the Cache.Insert() method to insert the object in the ASP.NET Cache instance. We implemented it using this constructor:
Cache.Insert(String key, object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration);
Cache.Insert("mykeyName", object, null,DateTime.Now.AddMinutes(Double.Parse(System.Configuration.ConfigurationManager.AppSettings["cacheExpirationTime"])), TimeSpan.Zero);
Our object is a list of MyClass instances containing the information we needed to save. Doing this inserts our object in the server side ASP.NET cache for the time we configured in the web.config file.
Now for retrieving the cache object when we needed we followed this implementation:
// Verifying if the object is on cache
if (cacheItem != null)
this.myObjectList = cacheItem;
Notice that we are doing a cast to List
This is a very out of the box basic implementation, but it solved our needs and might help you on your projects too.
The very cool thing about it is that you can save any object in the ASP.NET cache instance, set the expiration time from the web.config file and retrieved any time you want. The Cache ASP.NET instance has other methods and properties so be sure to check them out.