Hello,
recently I've been exploring performance gains that we can achieve by using 2nd level cache with Hibernate.
There are some entities that I want to keep in memory forever. They change very rarely and are not that numerous to begin with. From what I understand, one can achieve by setting lifespan and max_idle to -1 on the caching region.
As a test I added caching to a few entities (EntityA, EntityB, EntityC). Preloading entities into the cache resulted in 3 entity cache regions being filled. All are in the form of:
<deployed-artefact>#<persistence-unit><class-name-with-package>
Each entity has it's own caching region, is there a benefit to that? I assume these regions retrieve their configuration from the "entity" region that is also defined in standalone-full.xml.
In persistence.xml I managed to override lifespan and max_idle using the property as such:
<property name="hibernate.cache.infinispan.my-ar.war#MyPersistenceUnit.path.to.entity.EntityA.eviction.wake_up_interval" value="2000"/>
I have bolded out the name of the caching region. This works but it's awfully inconvenient. I would have to do this 2-3 times for each Entity!
Is there an easier solution? I know I can assign a specific caching region for each Entity using @Cache(region ="some region"). And then I can configure the properties for this specific region. Would that be reasonable? Is there a penalty for having 10 entities in the same caching region?
Thanks,
Aljaž