How many types of cache is there in asp.net and how can implement it ?
2 Answers
There is 1 Cache object, that you can use more or less like the Application object
And there is Output caching, per page or per user control.
You would use the Cache object like this (there are overloads):
Cache.Insert("myKey", myValue, null, DateTime.Now.AddMinutes(2),
System.Web.Caching.Cache.NoSlidingExpiration);
And for outputcaching, you can use this line below the <%@ Page %> line:
<%@ OutputCache Duration="120" VaryByParam="myParam"%>
2 Comments
Jim Schubert
And other forms of State Management can be found here: msdn.microsoft.com/en-us/library/75x4ha6s.aspx
Steve
Another overview of persistence, 9 options: msdn.microsoft.com/en-us/magazine/cc300437.aspx#S8
You can use the CacheManager http://msdn.microsoft.com/en-us/library/cc467894.aspx from the Enterprise Library or if you want a distributed cache you can go for Memcached http://memcached.org/