Geeks With Blogs
Ramesh Blog .NET Dash

One of the most interesting changes in the Whidbey's Cache object is that it now supports custom types of cache dependencies. In brief, a cache dependency represents a logical dependency between a cached item and a file(s), folder(s), or another cached item(s). When the dependency is broken (i.e., the file/folder/item changes), the bound cached item is removed from the cache.

CacheDependency dep = new CacheDependency(fileName, dateTime);
cache.Insert(key, value, dep);

In ASP.NET 1.1, the CacheDependency class is sealed and cannot be inherited to create custom classes. In ASP.NET 2.0 this is going to change. The benefit is that you can now extend the range of sensitive objects and use your own objects in addition to files, folders, and other cached items.

The most common type of custom dependency is a dependency set on a database table. For example, you run a query, store the results in a DataSet and place the DataSet into the Cache. Next, whenever the contents of the table changes the ASP.NET Cache automatically invalidates the entry meaning that it is time for you to refresh the data. This functionality, though, will be provided as a standalone class named SqlCacheDependency. It is worth noticing that this class works only with SQL Server 7.0 and newer and that the behavior changes significantly if you use SQL Server Yukon. (You can get a finer control over the changes in this case.)

Posted on Tuesday, January 6, 2004 6:23 AM | Back to top


Comments on this post: Cache Dependency in ASP.NET 2.0

# re: Cache Dependency in ASP.NET 2.0
Requesting Gravatar...
Hi,
How can i cache and uncache the page, showing current date and time, depending upon changes in the database table using Sql Server YUKON.

Regards,
Sachin
Left by Sachin on Apr 21, 2004 7:01 AM

# Cache Dependency in ASP.NET 1.1
Requesting Gravatar...
Hi ,
I want to using Caching in ASP.NET 1.1 and what to uncache if there is any change in database (SQL 2000) is there any way to do it with minimum efforts.

Thanks,
Bhavin Shah
Left by Bhavin Sha on Jun 22, 2006 2:08 PM

# Cache Dependency in ASP.NET 1.1
Requesting Gravatar...
Hi ,
I want to using Caching in ASP.NET 1.1 and what to uncache if there is any change in database (SQL 2000) is there any way to do it with minimum efforts.

Thanks,
Bhavin Shah
(bhavin.shah@fasttrackteam.com)
Left by Bhavin Shah on Jun 22, 2006 2:09 PM

# re: Cache Dependency in ASP.NET 2.0
Requesting Gravatar...
Hi, i read your article. It's nice to see, but some other articles represent that "we have used sql cache from sql 2000" I dont know which is applicable in the current IT. Can u clarify me, which is possible in sql2000 itself?
Left by sabarish on Jun 30, 2008 7:18 AM

# re: Cache Dependency in ASP.NET 2.0
Requesting Gravatar...
How to use system.web.caching.cachingdependency in .NET using ORacle database.......i am not using the oracle.web.caching..........

Left by leo on Jun 05, 2009 1:43 AM

# re: Cache Dependency in ASP.NET 2.0
Requesting Gravatar...
one has to keep into mind the limitations of asp.net cache as well (in-proc and stand alone nature). here is a good read about it

http://www.alachisoft.com/ncache/asp-net-cache.html
Left by watson on Feb 15, 2011 7:03 AM

Your comment:
 (will show your gravatar)


Copyright © Ramesh Arimilli | Powered by: GeeksWithBlogs.net