O'Reilly logo

NHibernate 4.x Cookbook - Second Edition by Jason Dentler, Alexander Zaytsev, Gunnar Liljas

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

Use the second-level cache

Caching is used frequently; rarely updated data can greatly improve the performance of websites and other high traffic applications. In this recipe, we'll configure NHibernate's cache, just as we would for a typical public facing website.

Getting ready

Complete the Getting Ready instructions at the beginning of Chapter 4, Queries.

How to do it...

  1. Add a reference to NHibernate.Caches.SysCache using NuGet Package manager console.
  2. Open or create a new App.config file in the project.
  3. In the configSections element, declare a section for the cache configuration:
    <section name="syscache"
    type="NHibernate.Caches.SysCache.SysCacheSectionHandler, 
    NHibernate.Caches.SysCache" />
  4. Add the syscache section:
    <syscache> <cache region="hourly" ...

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