Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance of hibernate Second Level Caching ehcache

We are considering using ehcache (1.6.0-beta5) to enable second level caching of a number of tables which are never modified. We have set up a read-only ehcache region for this table and currently it seems to be working fine. The Hibnerate POJOs stored in the cache are all immutable.

One of the developers here raised an issue that there is a significant performance decrease in the time taken to 'hydrate' objects from the ehcache, that is, the mapping from ehcache's internal representation of an entity to an actual java object. Instead he suggested we store objects manually in a cache of our own. This would require significant modification of our code and I have reservations on how big the improvement would be.

My questions are:

  1. Is this decrease in performance really significant?
  2. If the entities are immutable in a read-only cache, would ehcache actually need to do any hydration at all? Couldn't it just store the objects directly?

Thanks for any help.

like image 850
Il-Bhima Avatar asked May 25 '09 09:05

Il-Bhima


1 Answers

You should profile the time it takes for hydration. And if that is significat (at least a couple of percents) you should think about changing code.

like image 183
Mihai Toader Avatar answered Oct 09 '22 03:10

Mihai Toader