Second Level Cache in Hibernate by R4R Team

Hibernate Session is a transaction-level cache of persistent data.Hibernate has the ability to configure a cluster or JVM-level (SessionFactory-level) cache on a class-by-class and collection-by-collection basis. we can plug in a clustered cache. We need to aware that caches are not having change mode to the persistent store by another application. So it can be called to configured to regularly expire cached data.


We have an another option in Hibernate which cache implementation to use by specifying the name of a class that implements org.hibernate.cache.CacheProvider using the property hibernate.cache.provider_class. Hibernate is combination of bundled with a number of own and plug it in as outlined above. we have to remember EhCache as the default cache provider.


We have given all cache provider in the table:


Cache

Provider class

Type

Cluster Safe

Query Cache Supported

Hashtable (not intended for production use)

org.hibernate.cache.HashtableCacheProvider

memory


Yes

EHCache

org.hibernate.cache.EhCacheProvider

memory, disk


Yes

OSCache

org.hibernate.cache.OSCacheProvider

memory, disk

Yes


SwarmCache

org.hibernate.cache.SwarmCacheProvider

clustered (ip multicast)

yes (clustered invalidation)


JBoss Cache 1.x

org.hibernate.cache.TreeCacheProvider

clustered (ip multicast)

transactional yes (replication)

yes (clock sync req.)

JBoss Cache 2

org.hibernate.cache.jbc2.JBossCacheRegionFactory

clustered (ip multicast)

transactional yes (replication or invalidation)

yes (clock sync req.)

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!