April 2, 2011, 8:15 a.m.
posted by ninjacat
Although the ASP.NET team hasn't completed all of the feature work for the ASP.NET Cache (at the time of this writing there is yet another coding milestone currently in progress), the features that are available address two of the main requests most customers had: support for database change notifications and the ability to inherit from CacheDependency. The remaining work items will include new APIs for managing partial page caching as well as new configuration for managing the Cache at the application level.
Database cache invalidations are different for Microsoft SQL Server 7 and 2000 versus Microsoft SQL Server "Yukon." Microsoft SQL Server 7 and 2000 support only table-level change notifications. Microsoft SQL Server "Yukon" supports more granular notifications (e.g., the results of a stored procedure).
There are three ways to enable a Microsoft SQL Server 7 or 2000 database for change notifications: the aspnet_regsqlcache.exe tool, the Sql CacheDependencyAdmin class, or the Web Administration Tool (see Chapter 6). In this chapter we looked at the aspnet_regsqlcache.exe tool and learned how to enable the database and tables, as well as return a listing of all tables within a database enabled for change notifications.
Enabling caching in your ASP.NET application is easy. You can either use the new sqldependency attribute of the <%@ OutputCache %> directive or create an instance of SqlCacheDependency directly. Either option will ensure that the page is dependent on the named database and table.
Finally, we learned about the changes to the CacheDependency class and how it is now designed so that you can inherit from it and create your own cache dependencies.
In the next chapter, we will look at the ASP.NET server controls, examining the new and changed features.