
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
808
|
Chapter 14: Web
for SQL Server 2005) for the SqlCacheDependency to fire correctly. The SqlCacheDependency
has a section in the application’s web.config file under configuration/system.web/
caching defining the parameters that the dependency operates under. There are
timeout settings for the polling time (for SQL Server 2000 as SQL Server 2005
doesn’t poll) and the connection time, as well as a link to the connection string to
use via its name. This connection string can be found in the web.config file in the
configuration/connectionStrings section. The two entries are shown here:
<caching>
<sqlCacheDependency enabled="True" pollTime="60000">
<databases>
<add name="pubs" connectionStringName="LocalPubs" pollTime="9000000" />
</databases>
</sqlCacheDependency>
</caching>
<connectionStrings>
<add name="LocalPubs" connectionString="Server=(local);Integrated
Security=True;Database=pubs;Persist Security Info=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
Discussion
The main scenario for using SqlDependencyCache is for data that is read frequently but
changes very infrequently. The data should be reasonably static as there is overhead
associated with keeping the cache in sync with the database table. While the
SqlDependencyCache is for use with Microsoft SQL Server, ...