O'Reilly logo

NHibernate 3 Beginner's Guide by Gabriel N. Schenker

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

Second level cache

We have seen that NHibernate provides a very efficient way to cache data. Unfortunately, this first level cache is bound to a session object. This means that each time a session is disposed, all the cached data is lost. Sometimes, we need to be a little bit more flexible. We might want to cache some data not just for the duration of a session's lifetime, but rather globally, and make it available to all session objects. For such scenarios, NHibernate introduces the concept of the second level cache.

The second level cache is defined per session factory and lives as long as the session factory is not disposed. Once an entity is loaded by its unique ID and the second level cache is active, the entity is available for all other ...

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