I see a lot of articles saying that using the secondary cache in Hibernate will improve performance, but not a lot about the disadvantages of using it. I don't want to treat the secondary cache as a magical "enable here for free better performance!" button. Can anyone describe the disadvantages of using the secondary cache so that I can be aware of the implications of using it?
Points quoted in the other answer seems valid. However, for me, the main disadvantages are something else:
Performance degrade. Yes, having caching do NOT necessary to give you better performance. Hibernate needs to do extra work to store and update the cache. If the entities cached are changed frequently and you are not querying them frequently, enabling the cache is just adding unnecessary extra burden.
Cache invalidation. In case your application has logics that perform updates by ways not by updating the entities (e.g. direct SQL update, update through other application, bulk HQL update (I am not very sure for the last case :P ) ), Hibernate will not know the entities are changed. Hence, when you do query, you will still get the image before update.
Disadvantages:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With