Share via


sqlCacheDependency Element for caching (ASP.NET Settings Schema)

Defines the settings used by the SqlCacheDependency class for database caching and table-based polling against either Microsoft SQL Server 2000 or SQL Server 2005. This configuration setting has no effect when you use the sqlCacheDependency element in conjunction with query notifications on SQL Server 2005.

configuration Element (General Settings Schema)
  system.web Element (ASP.NET Settings Schema)
    caching Element (ASP.NET Settings Schema)
      sqlCacheDependency Element for caching (ASP.NET Settings Schema)

<sqlCacheDependency enabled="true|false" 
                    pollTime="number">
    <databases>...</databases>
</sqlCacheDependency>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

enabled

Required Boolean attribute.

Indicates whether changes are being polled for.

pollTime

Optional Int32 attribute.

Sets the frequency with which the SqlCacheDependency class instance polls the database table for changes. This value corresponds to the number of milliseconds between successive pollings. It cannot be set to less than 500 milliseconds.

The default value is 1 minute.

Child Elements

Element

Description

databases

Optional element.

Contains one or more named SQL connections that can be used by the SqlCacheDependency class instance.

Parent Elements

Element

Description

configuration

The required root element in every configuration file used by the common language runtime and the .NET Framework applications.

system.web

Specifies the root element for the ASP.NET configuration settings in a configuration file. Contains elements that configure ASP.NET Web applications and control how the applications behave.

caching

Configures the cache settings for a Web application.

Remarks

Default Configuration

The following default sqlCacheDependency element is not explicitly configured in the machine configuration file or in the root Web.config file, but is the default configuration returned by application in the .NET Framework version 2.0.

<sqlCacheDependency enabled = "true" 
  pollTime = "60000">
  <databases>
    <add name = "" 
      connectionStringName = "" 
      pollTime = "60000"/>
  </databases>
</sqlCacheDependency>

Example

The following example adds a SqlCacheDependency object to an ASP.NET application.

<sqlCacheDependency enabled="true" pollTime="30000">
  <databases>
    <add name="Pubs" connectionStringName="PubsConn" />
  </databases>
</sqlCacheDependency>

Element Information

Configuration section handler

System.Web.Configuration.SqlCacheDependencySection

Configuration member

SqlCacheDependency

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Requirements

IIS 5.0, 5.1 and 6.0

.NET Framework 2.0

Visual Studio 2005

See Also

Tasks

How to: Configure Specific Directories Using Location Settings

How to: Lock ASP.NET Configuration Settings

Concepts

ASP.NET Caching Overview

ASP.NET Configuration File Hierarchy and Inheritance

Securing ASP.NET Configuration

ASP.NET Configuration Scenarios

Reference

system.web Element (ASP.NET Settings Schema)

configuration Element (General Settings Schema)

caching Element (ASP.NET Settings Schema)

databases Element for sqlCacheDependency for caching (ASP.NET Settings Schema)

System.Configuration

System.Web.Configuration

Other Resources

General Configuration Settings (ASP.NET)

ASP.NET Configuration Settings

Administering ASP.NET Web Sites

ASP.NET Configuration Files

ASP.NET Configuration API