Skip to content

Commit 253b30d

Browse files
Document CoreMemoryCache
1 parent a786c8e commit 253b30d

File tree

1 file changed

+67
-7
lines changed

1 file changed

+67
-7
lines changed

doc/reference/modules/nhibernate_caches.xml

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
<para>
5151
Uses <classname>Bamboo.Prevalence</classname> as the cache provider. Open the
5252
file <filename>Bamboo.Prevalence.license.txt</filename> for more information about its license;
53-
you can also visit its <ulink url="http://bbooprevalence.sourceforge.net/">website</ulink>.
54-
Also see <xref linkend="NHibernate.Caches.Prevalence" />.
53+
you can also visit its <ulink url="http://bbooprevalence.sourceforge.net/">website</ulink>. This
54+
provider is available for the .Net Framework only. Also see <xref linkend="NHibernate.Caches.Prevalence" />.
5555
</para>
5656
</listitem>
5757
</varlistentry>
@@ -62,7 +62,7 @@
6262
Uses <classname>System.Web.Caching.Cache</classname> as the cache provider. This means that you can
6363
rely on ASP.NET caching feature to understand how it works. For more information, read (on the MSDN):
6464
<ulink url="https://msdn.microsoft.com/en-us/library/6hbbsfk6.aspx">Caching Application Data</ulink>.
65-
Also see <xref linkend="NHibernate.Caches.SysCache" />.
65+
This provider is available for the .Net Framework only. Also see <xref linkend="NHibernate.Caches.SysCache" />.
6666
</para>
6767
</listitem>
6868
</varlistentry>
@@ -75,7 +75,7 @@
7575
expire when the relevant data in the database changes.
7676
</para>
7777
<para>
78-
SysCache2 requires Microsoft SQL Server 2000 or higher.
78+
SysCache2 requires Microsoft SQL Server 2000 or higher. This provider is available for the .Net Framework only.
7979
</para>
8080
<para>
8181
See <xref linkend="NHibernate.Caches.SysCache2" />.
@@ -87,7 +87,8 @@
8787
<listitem>
8888
<para>
8989
Uses <literal>Memcached</literal>. See <ulink url="https://memcached.org/">memcached homepage</ulink>
90-
for more information on Memcached. Also see <xref linkend="NHibernate.Caches.EnyimMemcached" />.
90+
for more information on Memcached. This provider is available for the .Net Framework only. Also see
91+
<xref linkend="NHibernate.Caches.EnyimMemcached" />.
9192
</para>
9293
</listitem>
9394
</varlistentry>
@@ -106,8 +107,17 @@
106107
<term><classname>NHibernate.Caches.RtMemoryCache</classname></term>
107108
<listitem>
108109
<para>
109-
Uses <classname>System.Runtime.Caching.MemoryCache.Default</classname> as the cache provider.
110-
See <xref linkend="NHibernate.Caches.RtMemoryCache" />.
110+
Uses <classname>System.Runtime.Caching.MemoryCache.Default</classname> as the cache provider. This provider
111+
is available for the .Net Framework only. See <xref linkend="NHibernate.Caches.RtMemoryCache" />.
112+
</para>
113+
</listitem>
114+
</varlistentry>
115+
<varlistentry>
116+
<term><classname>NHibernate.Caches.CoreMemoryCache</classname></term>
117+
<listitem>
118+
<para>
119+
Uses <classname>Microsoft.Extensions.Caching.Memory.MemoryCache</classname> as the cache provider. This provider
120+
is available as a .Net Standard NuGet package. See <xref linkend="NHibernate.Caches.CoreMemoryCache" />.
111121
</para>
112122
</listitem>
113123
</varlistentry>
@@ -641,4 +651,54 @@
641651
</example>
642652
</section>
643653

654+
<section id="NHibernate.Caches.CoreMemoryCache">
655+
<title>CoreMemoryCache Configuration</title>
656+
<para>
657+
CoreMemoryCache relies on <classname>Microsoft.Extensions.Caching.Memory.MemoryCache</classname> for the
658+
underlying implementation.
659+
The following NHibernate configuration settings are available:
660+
</para>
661+
662+
<variablelist>
663+
<varlistentry>
664+
<term><literal>cache.default_expiration</literal></term>
665+
<listitem>
666+
Number of seconds to wait before expiring each item.
667+
Defaults to <literal>300</literal>. It can also be set programmatically on the NHibernate
668+
configuration object under the name <literal>expiration</literal>, which then takes precedence
669+
over <literal>cache.default_expiration</literal>.
670+
</listitem>
671+
</varlistentry>
672+
<varlistentry>
673+
<term><literal>cache.use_sliding_expiration</literal></term>
674+
<listitem>
675+
Should the expiration be sliding? A sliding expiration is reinitialized at each get.
676+
Defaults to <literal>false</literal>.
677+
</listitem>
678+
</varlistentry>
679+
</variablelist>
680+
681+
<para>
682+
CoreMemoryCache has a config file section handler to allow configuring different expirations for
683+
different regions, and configuring the <literal>MemoryCache</literal> expiration scan frequency.
684+
Here is an example:
685+
</para>
686+
687+
<example>
688+
<programlisting><![CDATA[<?xml version="1.0" encoding="utf-8" ?>
689+
<configuration>
690+
<configSections>
691+
<section name="corememorycache"
692+
type="NHibernate.Caches.CoreMemoryCache.CoreMemoryCacheSectionHandler,NHibernate.Caches.CoreMemoryCache"
693+
/>
694+
</configSections>
695+
696+
<corememorycache expiration-scan-frequency="00:05:00">
697+
<cache region="foo" expiration="500" />
698+
<cache region="bar" expiration="300" sliding="true" />
699+
</corememorycache>
700+
</configuration>]]></programlisting>
701+
</example>
702+
</section>
703+
644704
</chapter>

0 commit comments

Comments
 (0)