O'Reilly logo

NHibernate 3.0 Cookbook by Jason Dentler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring the cache with code

NHibernate also provides an option for cache configuration with the NHibernate.Cfg. Loquacious namespace. In this recipe, I'll show you how to configure the second level cache with code.

Getting ready

  1. Complete the Configuring NHibernate with App.config recipe from Chapter 1.
  2. Download the NHibernate Caches binary files from SourceForge at http://sourceforge.net/projects/nhcontrib/files/.
  3. Extract NHibernate.Caches.SysCache.dll to your solution's Lib folder.

How to do it...

  1. In the configSections element of App.config, declare a section for our cache provider's configuration:
    <section name="syscache"
        type="NHibernate.Caches.SysCache.SysCacheSectionHandler, 
              NHibernate.Caches.SysCache" />
  2. After the hibernate-configuration section, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required