Caching
We have briefly touched the topic of caching in multiple places earlier. Caching support in NHibernate is more extensive than most of the frameworks that I have come across so far. Following are the three different types of caches available in NHibernate:
- Session level cache:
ISession
caches every entity that it loads from the database. This is default behavior and cannot be changed or turned off. - Query cache: At individual query level, you can specify if the output of that query needs to be cached. This cache is shared across sessions.
- Second level cache: This is similar to session level cache but it is shared across all the sessions in a session factory. Due to its shared nature, this cache is most complex of all and comes with settings that you can use to fine tune use of second level cache in your application.
Let's dive into each type of cache in more detail to understand how to enable, disable, and make use of each cache.
Session level cache
We have come across references to...