The CacheDependency Class

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.

  • Time : After a specific duration of time, the item is removed from the Cache . This feature is most evident in the page output caching features of ASP.NET.

  • File : If a file or files change, the item is removed from the Cache .

  • Key : If another Cache key changes, the item is removed from the Cache .

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 !



A First Look at ASP. NET v. 2.0 2003
A First Look at ASP. NET v. 2.0 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 90

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net