Version 1.0 of ASP.NET introduced the ASP.NET Cache , an application-specific hashtable used to store frequently accessed data. The structure and API of the Cache is very similar to two other structures, Application and Session , insofar as they all support similar APIs. Application is most similar to the Cache because it is global to the application, whereas Session is memory set aside for each user . The biggest differentiator between Application and Cache is the Cache 's support of Cache dependencies. Cache dependencies allow developers to build solutions that can automatically remove cached items from the Cache on the occurrence of certain events. The support events are listed below.
The above functionality is encapsulated in the CacheDependency class found in the System.Web.Caching namespace. While these three dependency features address a great number of the needs for most developers, people are constantly requesting the ability to add more. For example, the dependency feature most requested is database dependencywhich Microsoft added to ASP.NET 2.0. Another common request is to generalize the CacheDependency class so that anyone can implement a CacheDependency (e.g., a cache dependency that relies on values returned from an XML Web Service). Microsoft has unsealed the CacheDependency class and has done other work to make it possible for you to extend CacheDependency ; in fact, this is just what was done for SqlCacheDependency ! |