1

I was reading about Nhibernate cache, can any body tell me, what is the advantage of Nhibernate cache over Asp.net cache techniques and when do we use Nhibernate cache over Asp.Net cache.

Nick Ryan
  • 2,662
  • 1
  • 17
  • 24
kamal
  • 739
  • 1
  • 9
  • 21

3 Answers3

2

They are fundamentally different things. The the purpose of the 1st and 2nd level NHibernate caches are to offload as much querying from the database as possible. There is a good SO article here:- What are First and Second Level caching in Hibernate?

Community
  • 1
  • 1
Nick Ryan
  • 2,662
  • 1
  • 17
  • 24
1

first of all lets understand the concept, NHibernate is a leading open source Object Relational Mapping (ORM) solution and simplifies database programming for .NET applications. By default it provides a standalone InProc (in process) first-level (L1) cache, or session-level cache. but if you are running in a multi-server environment, then the first level cache may not very scalable and may ends up with some performance issues as it has to make very frequent trips to the database as the data is distributed over multiple servers.NHibernate also supports a second-level cache to be plugged in to exploit the benefits of a sophisticated enterprise-grade caching infrastructure.

ASP.NET Cache object within the Application scope of ASP.NET. And this allows you to cache application data and reduce those expensive database trips and improve your ASP.NET performance. Here is how ASP.NET Cache is typically used.ASP.NET Cache is a stand-alone in-process (InProc) cache and therefore has many limitations if your application is deployed in a load-balanced web farm.

please read these posts to understand further.

Ravian
  • 64
  • 1
0

I just wanted to add a few words extending your question, both of this cache eventually do the same functionality, they extend the data from the DB to prevent accessing it frequently. .net cache has some advantage in term of caching since it allow you to cache everything, like state data that doesn't need to exist in the DB in the first place. second level cache is harder to control and configure.

If you are looking for more advance cache solutions, you need to check other products such as ncache, GigaSpaces and Gemfire. those can provide a scale/high available caching solution.

Guy Lubovitch
  • 180
  • 1
  • 6