|
125 | 125 | <programlisting>
|
126 | 126 | <property name="cache.provider_class"><literal>XXX</literal></property><co id="hibernate.cache.provider_class-co" linkends="hibernate.cache.provider_class"/>
|
127 | 127 | <property name="cache.default_expiration"><literal>120</literal></property><co id="nhcaches-expiration-co" linkends="nhcaches-expiration"/>
|
| 128 | +<property name="cache.use_sliding_expiration"><literal>true</literal></property><co id="nhcaches-sliding-co" linkends="nhcaches-sliding"/> |
128 | 129 | </programlisting>
|
129 | 130 | <calloutlist>
|
130 | 131 | <callout arearefs="hibernate.cache.provider_class-co" id="hibernate.cache.provider_class">
|
|
138 | 139 | <callout arearefs="nhcaches-expiration-co" id="nhcaches-expiration">
|
139 | 140 | <para>
|
140 | 141 | The <literal>expiration</literal> value is the number of seconds you wish
|
141 |
| - to cache each entry (here two minutes). This example applies to SysCache only. |
| 142 | + to cache each entry (here two minutes). Not all providers support this setting, it may |
| 143 | + be ignored. Check their respective documentation. |
| 144 | + </para> |
| 145 | + </callout> |
| 146 | + <callout arearefs="nhcaches-sliding-co" id="nhcaches-sliding"> |
| 147 | + <para> |
| 148 | + The <literal>use_sliding_expiration</literal> value is whether you wish to use a |
| 149 | + sliding expiration or not. Defaults to <literal>false</literal>. |
| 150 | + Not all providers support this setting, it may be ignored. Check their respective documentation. |
142 | 151 | </para>
|
143 | 152 | </callout>
|
144 | 153 | </calloutlist>
|
|
190 | 199 | <section id="NHibernate.Caches.SysCache">
|
191 | 200 | <title>SysCache Configuration</title>
|
192 | 201 | <para>
|
193 |
| - As SysCache relies on <classname>System.Web.Caching.Cache</classname> for the underlying implementation, |
194 |
| - the configuration is based on the available options that make sense for NHibernate to utilize. |
| 202 | + As SysCache relies on <classname>System.Web.Caching.Cache</classname> for the underlying implementation. |
| 203 | + Following NHibernate configuration settings are available: |
195 | 204 | </para>
|
196 | 205 |
|
197 | 206 | <variablelist>
|
198 | 207 | <varlistentry>
|
199 | 208 | <term><literal>expiration</literal></term>
|
200 | 209 | <listitem>
|
201 | 210 | Number of seconds to wait before expiring each item.
|
| 211 | + Takes precedence over <literal>cache.default_expiration</literal>. |
| 212 | + If none of them are defined, defaults to <literal>300</literal>. |
| 213 | + </listitem> |
| 214 | + </varlistentry> |
| 215 | + <varlistentry> |
| 216 | + <term><literal>cache.use_sliding_expiration</literal></term> |
| 217 | + <listitem> |
| 218 | + Should the expiration be sliding? A sliding expiration is reinitialized at each get. |
| 219 | + Defaults to <literal>false</literal>. |
202 | 220 | </listitem>
|
203 | 221 | </varlistentry>
|
204 | 222 | <varlistentry>
|
205 | 223 | <term><literal>priority</literal></term>
|
206 | 224 | <listitem>
|
207 | 225 | A numeric cost of expiring each item, where 1 is a low cost, 5 is the highest, and 3 is normal.
|
208 |
| - Only values 1 through 5 are valid. |
| 226 | + Only values 1 through 5 are valid. 6 is a special value corresponding to |
| 227 | + <literal>NotRemovable</literal>, it should not be used. |
209 | 228 | </listitem>
|
210 | 229 | </varlistentry>
|
211 | 230 | </variablelist>
|
212 | 231 |
|
213 | 232 | <para>
|
214 | 233 | SysCache has a config file section handler to allow configuring different expirations and priorities for
|
215 |
| - different regions. Here's an example: |
| 234 | + different regions. Here is an example: |
216 | 235 | </para>
|
217 | 236 |
|
218 | 237 | <example>
|
|
225 | 244 |
|
226 | 245 | <syscache>
|
227 | 246 | <cache region="foo" expiration="500" priority="4" />
|
228 |
| - <cache region="bar" expiration="300" priority="3" /> |
| 247 | + <cache region="bar" expiration="300" priority="3" sliding="true" /> |
229 | 248 | </syscache>
|
230 | 249 | </configuration>]]></programlisting>
|
231 | 250 | </example>
|
|
241 | 260 | MSDN documentation.
|
242 | 261 | </para>
|
243 | 262 |
|
| 263 | + <para> |
| 264 | + Following NHibernate configuration settings are available: |
| 265 | + </para> |
| 266 | + |
| 267 | + <variablelist> |
| 268 | + <varlistentry> |
| 269 | + <term><literal>expiration</literal></term> |
| 270 | + <listitem> |
| 271 | + Number of seconds to wait before expiring each item. |
| 272 | + Takes precedence over <literal>cache.default_expiration</literal>. |
| 273 | + If none of them are defined, defaults to <literal>300</literal>. |
| 274 | + </listitem> |
| 275 | + </varlistentry> |
| 276 | + <varlistentry> |
| 277 | + <term><literal>cache.use_sliding_expiration</literal></term> |
| 278 | + <listitem> |
| 279 | + Should the expiration be sliding? A sliding expiration is reinitialized at each get. |
| 280 | + Defaults to <literal>false</literal>. |
| 281 | + </listitem> |
| 282 | + </varlistentry> |
| 283 | + </variablelist> |
| 284 | + |
244 | 285 | <para>
|
245 | 286 | To configure cache regions with SqlCacheDependencies a <literal>syscache2</literal> config section must be
|
246 | 287 | defined in the application's configuration file. See the sample below.
|
|
462 | 503 | <example>
|
463 | 504 | <title>Relative Expiration</title>
|
464 | 505 |
|
465 |
| - <programlisting><![CDATA[<cacheRegion name="Product" relativeExpiration="300" priority="High" />]]></programlisting> |
| 506 | + <programlisting><![CDATA[<cacheRegion name="Product" relativeExpiration="300" priority="High" useSlidingExpiration="true" />]]></programlisting> |
466 | 507 | </example>
|
467 | 508 |
|
468 | 509 | <example>
|
|
478 | 519 | <listitem>
|
479 | 520 | <para>
|
480 | 521 | Number of seconds that an individual item will exist in the cache before being removed.
|
| 522 | + Defaults to <literal>300</literal> if neither <literal>relativeExpiration</literal> nor |
| 523 | + <literal>timeOfDayExpiration</literal> are defined, and if no expiration settings are |
| 524 | + defined in NHibernate configuration. |
| 525 | + </para> |
| 526 | + </listitem> |
| 527 | + </varlistentry> |
| 528 | + <varlistentry> |
| 529 | + <term><literal>useSlidingExpiration</literal></term> |
| 530 | + <listitem> |
| 531 | + <para> |
| 532 | + Should the expiration be sliding? A sliding expiration is reinitialized at each get. |
| 533 | + Defaults to <literal>false</literal> if not defined in NHibernate configuration. |
481 | 534 | </para>
|
482 | 535 | </listitem>
|
483 | 536 | </varlistentry>
|
|
504 | 557 |
|
505 | 558 | </section>
|
506 | 559 |
|
| 560 | + <section id="NHibernate.Caches.RtMemoryCache"> |
| 561 | + <title>Runtime Memory Configuration</title> |
| 562 | + <para> |
| 563 | + As runtime memory relies on <classname>System.Runtime.Caching.MemoryCache</classname> for the |
| 564 | + underlying implementation. |
| 565 | + Following NHibernate configuration settings are available: |
| 566 | + </para> |
| 567 | + |
| 568 | + <variablelist> |
| 569 | + <varlistentry> |
| 570 | + <term><literal>expiration</literal></term> |
| 571 | + <listitem> |
| 572 | + Number of seconds to wait before expiring each item. |
| 573 | + Takes precedence over <literal>cache.default_expiration</literal>. |
| 574 | + If none of them are defined, defaults to <literal>300</literal>. |
| 575 | + </listitem> |
| 576 | + </varlistentry> |
| 577 | + <varlistentry> |
| 578 | + <term><literal>cache.use_sliding_expiration</literal></term> |
| 579 | + <listitem> |
| 580 | + Should the expiration be sliding? A sliding expiration is reinitialized at each get. |
| 581 | + Defaults to <literal>false</literal>. |
| 582 | + </listitem> |
| 583 | + </varlistentry> |
| 584 | + </variablelist> |
| 585 | + |
| 586 | + <para> |
| 587 | + RtMemoryCache has a config file section handler to allow configuring different expirations for |
| 588 | + different regions. Here is an example: |
| 589 | + </para> |
| 590 | + |
| 591 | + <example> |
| 592 | + <programlisting><![CDATA[<?xml version="1.0" encoding="utf-8" ?> |
| 593 | +<configuration> |
| 594 | + <configSections> |
| 595 | + <section name="syscache" |
| 596 | + type="NHibernate.Caches.SysCache.SysCacheSectionHandler,NHibernate.Caches.SysCache" /> |
| 597 | + </configSections> |
| 598 | +
|
| 599 | + <syscache> |
| 600 | + <cache region="foo" expiration="500" /> |
| 601 | + <cache region="bar" expiration="300" sliding="true" /> |
| 602 | + </syscache> |
| 603 | +</configuration>]]></programlisting> |
| 604 | + </example> |
| 605 | + </section> |
| 606 | + |
507 | 607 | </chapter>
|
0 commit comments