Reputation: 5411
In my project I have to put different table data to different L2 caches based on usage. Some tables require replicated cache while others can afford only distributed cache. Is this kind of configuration is possible with hibernate ?
In hibernate.properties we can only specify one cache
hibernate.cache.infinispan.entity.cfg=replicated-cache-entity
hibernate.cache.infinispan.collection.cfg=replicated-cache-entity
This cache is configured in ininispan.xml
<namedCache name="replicated-cache-entity">
<clustering mode="replication">
<stateRetrieval fetchInMemoryState="false" timeout="20000"/>
<sync replTimeout="20000"/>
</clustering>
</namedCache>
Is there a way to specify different caches ( cache names in infinispan ) for single table or class ?
OR
Is there a way to intercept hibernate L2 cache calls like infinispan interceptors ?
Upvotes: 2
Views: 336
Reputation: 7204
The Infinispan user guide also mentions per-entity cache configurations:
On top of that, this finer grained cache definition enables users to define cache settings on a per entity/collection basis. For example:
<!-- If using Hibernate, add to your hibernate.cfg.xml -->
<property name="hibernate.cache.infinispan.com.acme.Person.cfg">
person-entity
</property>
<property name="hibernate.cache.infinispan.com.acme.Person.addresses.cfg">
addresses-collection
</property>
Upvotes: 3