0
Sponsored Links


Ad by Google
In our previous post we have seen a example of  Hibernate Data Filter. In this post we are going to list down the few Cache providers and Cache Strategies then we start with example of second level cache in hibernate in our next post.

Hibernate Session is a transaction level cache of persistent data. It is also possible to configure a cluster or JVM (Session Factory) level cache. Second level cache is used to reduce the performance of application by reducing the database hit. To configure second level cache we need to use at least one cache provider.
There are different types of Cache providers and they can be integrated with Hibernate.

Here are few Popular Cache Providers:
  1. EHCache (Very Popular)
  2. OSCache
  3. SwarmCache
  4. JBoss Cache
  5. Hashtable

To configure second level cache in hibernate you need at least one Cache Provider, Once you opted your cache provider then you have to select at least one Cache Strategy.

Here are the list of Caching Strategies supported by Hibernate.
  1. Read Only: Strategy can be opted, whenever your application needs to read, but not updated instance of persistent class, read only strategy is very popular and optimal performance strategy.
  2. Read Write: Strategy can be opted, whenever your application needs updated data. This cache strategy should never be used, if serializable transaction isolation is required. This strategy will gives you the updated data from the database, but cache are not aware of changes made to the persistent(database) by other application/api/manual, so use hibernate only to update the data into the database.
  3. Nonrestricted Read Write: Strategy can be opted, If your application only occasionally needs to update the data.
  4. Transactional: This strategy support fully transaction cache providers such as JBoss TreeCache and they can only used in JTA environment.

References:
Reference 1
Sponsored Links

0 comments:

Post a Comment