|
1 |
| ---- |
| 1 | +--- |
2 | 2 | layout:
|
3 | 3 | ---
|
4 | 4 | <!doctype html>
|
|
39 | 39 | SQL dependency-based expiration, meaning that it is possible to configure certain cache regions to automatically
|
40 | 40 | expire when the relevant data in the database changes.
|
41 | 41 | </p><p>
|
42 |
| - SysCache2 requires Microsoft SQL Server 2000 or higher and .NET Framework version 2.0 or higher. |
| 42 | + SysCache2 requires Microsoft SQL Server 2000 or higher. |
43 | 43 | </p></dd><dt><span class="term"><tt class="classname">NHibernate.Caches.MemCache</tt></span></dt><dd><p>
|
44 | 44 | Uses <tt class="literal">memcached</tt>. See <a href="https://memcached.org/" target="_top">memcached homepage</a>
|
45 | 45 | for more information.
|
|
105 | 105 | </dd></dl></div><p>
|
106 | 106 | SysCache has a config file section handler to allow configuring different expirations and priorities for
|
107 | 107 | different regions. Here's an example:
|
108 |
| - </p><div class="example"><a name="d0e15399"></a><p class="title"><b>Example 26.1. </b></p><pre class="programlisting"><?xml version="1.0" encoding="utf-8" ?> |
| 108 | + </p><div class="example"><a name="d0e15524"></a><p class="title"><b>Example 26.1. </b></p><pre class="programlisting"><?xml version="1.0" encoding="utf-8" ?> |
109 | 109 | <configuration>
|
110 | 110 | <configSections>
|
111 | 111 | <section name="syscache"
|
|
124 | 124 | </p><p>
|
125 | 125 | To configure cache regions with SqlCacheDependencies a <tt class="literal">syscache2</tt> config section must be
|
126 | 126 | defined in the application's configuration file. See the sample below.
|
127 |
| - </p><div class="example"><a name="d0e15412"></a><p class="title"><b>Example 26.2. </b></p><pre class="programlisting"> |
| 127 | + </p><div class="example"><a name="d0e15537"></a><p class="title"><b>Example 26.2. </b></p><pre class="programlisting"> |
128 | 128 | <configSections>
|
129 | 129 | <section name="syscache2"
|
130 | 130 | type="NHibernate.Caches.SysCache2.SysCacheSection, NHibernate.Caches.SysCache2"/>
|
131 |
| -</configSections></pre></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e15415"></a>26.4.1. Table-based Dependency</h3></div></div><div></div></div><p> |
| 131 | +</configSections></pre></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e15540"></a>26.4.1. Table-based Dependency</h3></div></div><div></div></div><p> |
132 | 132 | A table-based dependency will monitor the data in a database table for changes. Table-based
|
133 |
| - dependencies are generally used for a SQL Server 2000 database but will work with SQL Server 2005 as |
| 133 | + dependencies are generally used for a SQL Server 2000 database but will work with SQL Server 2005 or superior as |
134 | 134 | well. Before you can use SQL Server cache invalidation with table based dependencies, you need to
|
135 | 135 | enable notifications for the database. This task is performed with the <span><b class="command">aspnet_regsql</b></span>
|
136 | 136 | command. With table-based notifications, the application will poll the database for changes at a
|
|
139 | 139 | </p><p>
|
140 | 140 | To configure the data in a cache region to be invalidated when data in an underlying table is changed,
|
141 | 141 | a cache region must be configured in the application's configuration file. See the sample below.
|
142 |
| - </p><div class="example"><a name="d0e15425"></a><p class="title"><b>Example 26.3. </b></p><pre class="programlisting"><syscache2> |
| 142 | + </p><div class="example"><a name="d0e15550"></a><p class="title"><b>Example 26.3. </b></p><pre class="programlisting"><syscache2> |
143 | 143 | <cacheRegion name="Product">
|
144 | 144 | <dependencies>
|
145 | 145 | <tables>
|
|
156 | 156 | The name of a database defined in the <tt class="literal">databases</tt> element for
|
157 | 157 | <tt class="literal">sqlCacheDependency</tt> for caching (ASP.NET Settings Schema) element of the
|
158 | 158 | application's <tt class="literal">Web.config</tt> file.
|
159 |
| - </dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e15461"></a>26.4.2. Command-Based Dependencies</h3></div></div><div></div></div><p> |
| 159 | + </dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e15586"></a>26.4.2. Command-Based Dependencies</h3></div></div><div></div></div><p> |
160 | 160 | A command-based dependency will use a SQL command to identify records to monitor for data changes.
|
161 | 161 | Command-based dependencies work only with SQL Server 2005.
|
162 | 162 | </p><p>
|
|
171 | 171 | </p><p>
|
172 | 172 | To configure the data in a cache region to be invalidated based on a SQL command, a cache region must
|
173 | 173 | be configured in the application's configuration file. See the samples below.
|
174 |
| - </p><div class="example"><a name="d0e15470"></a><p class="title"><b>Example 26.4. Stored Procedure</b></p><pre class="programlisting"><cacheRegion name="Product" priority="High" > |
| 174 | + </p><div class="example"><a name="d0e15595"></a><p class="title"><b>Example 26.4. Stored Procedure</b></p><pre class="programlisting"><cacheRegion name="Product" priority="High" > |
175 | 175 | <dependencies>
|
176 | 176 | <commands>
|
177 | 177 | <add name="price"
|
178 | 178 | command="ActiveProductsStoredProcedure"
|
179 | 179 | isStoredProcedure="true"/>
|
180 | 180 | </commands>
|
181 | 181 | </dependencies>
|
182 |
| -</cacheRegion></pre></div><div class="example"><a name="d0e15475"></a><p class="title"><b>Example 26.5. SELECT Statement</b></p><pre class="programlisting"><cacheRegion name="Product" priority="High"> |
| 182 | +</cacheRegion></pre></div><div class="example"><a name="d0e15600"></a><p class="title"><b>Example 26.5. SELECT Statement</b></p><pre class="programlisting"><cacheRegion name="Product" priority="High"> |
183 | 183 | <dependencies>
|
184 | 184 | <commands>
|
185 | 185 | <add name="price"
|
|
199 | 199 | use for registering the cache dependency for change notifications. If no value is supplied for
|
200 | 200 | <tt class="literal">connectionName</tt>, the unnamed connection supplied by the provider will be
|
201 | 201 | used.
|
202 |
| - </dd></dl></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e15531"></a>26.4.3. Aggregate Dependencies</h3></div></div><div></div></div><p> |
| 202 | + </dd></dl></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e15656"></a>26.4.3. Aggregate Dependencies</h3></div></div><div></div></div><p> |
203 | 203 | Multiple cache dependencies can be specified. If any of the dependencies triggers a change
|
204 | 204 | notification, the data in the cache region will be invalidated. See the samples below.
|
205 |
| - </p><div class="example"><a name="d0e15536"></a><p class="title"><b>Example 26.6. Multiple commands</b></p><pre class="programlisting"><cacheRegion name="Product"> |
| 205 | + </p><div class="example"><a name="d0e15661"></a><p class="title"><b>Example 26.6. Multiple commands</b></p><pre class="programlisting"><cacheRegion name="Product"> |
206 | 206 | <dependencies>
|
207 | 207 | <commands>
|
208 | 208 | <add name="price"
|
|
212 | 212 | command="Select quantityAvailable from dbo.VideoAvailability"/>
|
213 | 213 | </commands>
|
214 | 214 | </dependencies>
|
215 |
| -</cacheRegion></pre></div><div class="example"><a name="d0e15541"></a><p class="title"><b>Example 26.7. Mixed</b></p><pre class="programlisting"><cacheRegion name="Product"> |
| 215 | +</cacheRegion></pre></div><div class="example"><a name="d0e15666"></a><p class="title"><b>Example 26.7. Mixed</b></p><pre class="programlisting"><cacheRegion name="Product"> |
216 | 216 | <dependencies>
|
217 | 217 | <commands>
|
218 | 218 | <add name="price"
|
|
225 | 225 | tableName=" VideoAvailability" />
|
226 | 226 | </tables>
|
227 | 227 | </dependencies>
|
228 |
| -</cacheRegion></pre></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e15546"></a>26.4.4. Additional Settings</h3></div></div><div></div></div><p> |
| 228 | +</cacheRegion></pre></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e15671"></a>26.4.4. Additional Settings</h3></div></div><div></div></div><p> |
229 | 229 | In addition to data dependencies for the cache regions, time based expiration policies can be specified
|
230 | 230 | for each item added to the cache. Time based expiration policies will not invalidate the data
|
231 | 231 | dependencies for the whole cache region, but serve as a way to remove items from the cache after they
|
232 | 232 | have been in the cache for a specified amount of time. See the samples below.
|
233 |
| - </p><div class="example"><a name="d0e15551"></a><p class="title"><b>Example 26.8. Relative Expiration</b></p><pre class="programlisting"><cacheRegion name="Product" relativeExpiration="300" priority="High" /></pre></div><div class="example"><a name="d0e15556"></a><p class="title"><b>Example 26.9. Time of Day Expiration</b></p><pre class="programlisting"><cacheRegion name="Product" timeOfDayExpiration="2:00:00" priority="High" /></pre></div><div class="variablelist"><p class="title"><b>Additional Configuration Properties</b></p><dl><dt><span class="term"><tt class="literal">relativeExpiration</tt></span></dt><dd><p> |
| 233 | + </p><div class="example"><a name="d0e15676"></a><p class="title"><b>Example 26.8. Relative Expiration</b></p><pre class="programlisting"><cacheRegion name="Product" relativeExpiration="300" priority="High" /></pre></div><div class="example"><a name="d0e15681"></a><p class="title"><b>Example 26.9. Time of Day Expiration</b></p><pre class="programlisting"><cacheRegion name="Product" timeOfDayExpiration="2:00:00" priority="High" /></pre></div><div class="variablelist"><p class="title"><b>Additional Configuration Properties</b></p><dl><dt><span class="term"><tt class="literal">relativeExpiration</tt></span></dt><dd><p> |
234 | 234 | Number of seconds that an individual item will exist in the cache before being removed.
|
235 | 235 | </p></dd><dt><span class="term"><tt class="literal">timeOfDayExpiration</tt></span></dt><dd><p>
|
236 | 236 | 24 hour based time of day that an item will exist in the cache until. 12am is specified as
|
|
0 commit comments