Data Caching
Data caching is (surprise!) the caching of data from a data source. As long as the cache is not expired, a request for data will be fulfilled from the cache rather than the original data source. If the cache is expired, for whatever reason, then fresh data will be obtained by the data source and the cache will be refreshed. There are many reasons the cache can expire, as you will see. These can include time outs, changed data, or changes to other objects.
There are two kinds of data caching
: DataSourceControl
caching and
SQL cache dependency
. Both are very useful.
DataSourceControl Caching
Data source controls, covered in Chapter 9, represent data in a data source, such as a database or an XML file. The abstract DataSourceControl
class has two controls derived from it: ObjectDataSource
and SqlDataSource
, from which AccessDataSource
is derived. Each of these derived classes (though not the base class) has a number of properties for implementing caching, listed in Table 17-1.
Table 17-1. Data source control properties for caching
Property |
Type |
Get |
Set |
Description |
---|---|---|---|---|
|
|
✗ |
✗ |
Length of time, in seconds, that data is cached before the cache is invalidated. The default value is |
|
|
✗ |
✗ |
Default is |
|
|
✗ |
✗ |
Get Programming ASP.NET, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.