Skip to content

Commit a148991

Browse files
Document caches settings.
1 parent 0424fcc commit a148991

File tree

1 file changed

+107
-7
lines changed

1 file changed

+107
-7
lines changed

doc/reference/modules/nhibernate_caches.xml

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
<programlisting>
126126
&lt;property name="cache.provider_class"&gt;<literal>XXX</literal>&lt;/property&gt;<co id="hibernate.cache.provider_class-co" linkends="hibernate.cache.provider_class"/>
127127
&lt;property name="cache.default_expiration"&gt;<literal>120</literal>&lt;/property&gt;<co id="nhcaches-expiration-co" linkends="nhcaches-expiration"/>
128+
&lt;property name="cache.use_sliding_expiration"&gt;<literal>true</literal>&lt;/property&gt;<co id="nhcaches-sliding-co" linkends="nhcaches-sliding"/>
128129
</programlisting>
129130
<calloutlist>
130131
<callout arearefs="hibernate.cache.provider_class-co" id="hibernate.cache.provider_class">
@@ -138,7 +139,15 @@
138139
<callout arearefs="nhcaches-expiration-co" id="nhcaches-expiration">
139140
<para>
140141
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.
142151
</para>
143152
</callout>
144153
</calloutlist>
@@ -190,29 +199,39 @@
190199
<section id="NHibernate.Caches.SysCache">
191200
<title>SysCache Configuration</title>
192201
<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:
195204
</para>
196205

197206
<variablelist>
198207
<varlistentry>
199208
<term><literal>expiration</literal></term>
200209
<listitem>
201210
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>.
202220
</listitem>
203221
</varlistentry>
204222
<varlistentry>
205223
<term><literal>priority</literal></term>
206224
<listitem>
207225
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.
209228
</listitem>
210229
</varlistentry>
211230
</variablelist>
212231

213232
<para>
214233
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:
216235
</para>
217236

218237
<example>
@@ -225,7 +244,7 @@
225244
226245
<syscache>
227246
<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" />
229248
</syscache>
230249
</configuration>]]></programlisting>
231250
</example>
@@ -241,6 +260,28 @@
241260
MSDN documentation.
242261
</para>
243262

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+
244285
<para>
245286
To configure cache regions with SqlCacheDependencies a <literal>syscache2</literal> config section must be
246287
defined in the application's configuration file. See the sample below.
@@ -462,7 +503,7 @@
462503
<example>
463504
<title>Relative Expiration</title>
464505

465-
<programlisting><![CDATA[<cacheRegion name="Product" relativeExpiration="300" priority="High" />]]></programlisting>
506+
<programlisting><![CDATA[<cacheRegion name="Product" relativeExpiration="300" priority="High" useSlidingExpiration="true" />]]></programlisting>
466507
</example>
467508

468509
<example>
@@ -478,6 +519,18 @@
478519
<listitem>
479520
<para>
480521
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.
481534
</para>
482535
</listitem>
483536
</varlistentry>
@@ -504,4 +557,51 @@
504557

505558
</section>
506559

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+
507607
</chapter>

0 commit comments

Comments
 (0)