This link (from the creator of Ehcache) says you should use SingletonEhCacheRegionFactory when you only have one Hibernate SessionFactory, and EhCacheRegionFactory when you have multiple.
But wouldn't EhCacheRegionFactory be a single instance anyway when you only have one SessionFactory?
So, what's better about SingletonEhCacheRegionFactory? Why not use EhCacheRegionFactory all the time since it can be used for one SessionFactory or multiple?
FYI: I'm using Ehcache 2.4.2 and Hibernate 3.6.5
The non-singleton EhCacheRegionFactory allows you to configure EHCache separately for each Hibernate instance using net.sf.ehcache.configurationResourceName property. The SingletonEhCacheRegionFactory shares the same EHCache configuration among all Hibernate session factories.
EHCache documentation recommends to use the non-singleton version.
Edit: This information applies to EHCache 2.8. Not sure how many things have changed in the latest version.
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