0

I'm using Infinispan 6.0.0 with Hibernate 4.3.6.

My config is:

    <!-- Default configuration is appropriate for entity/collection caching. -->
   <namedCache name="entity">
      <clustering mode="invalidation">
         <stateTransfer fetchInMemoryState="false" timeout="20000"/>
         <sync replTimeout="20000"/>
      </clustering>
      <locking isolationLevel="READ_COMMITTED" concurrencyLevel="1000"
               lockAcquisitionTimeout="15000" useLockStriping="false"/>
      <!-- Eviction configuration.  WakeupInterval defines how often the eviction thread runs, in milliseconds.  
           0 means the eviction thread will never run.  A separate executor is used for eviction in each cache. -->
      <eviction maxEntries="${infinispan.maxEntries:10000}" strategy="LRU"/>
      <expiration maxIdle="${infinispan.maxIdle:-1}" wakeUpInterval="5000"/>
      <!-- <transaction transactionMode="TRANSACTIONAL" autoCommit="false"
                   lockingMode="OPTIMISTIC"/> -->
   </namedCache>

The system properties are not set, so the defaults are applied (10.000, -1).

As I understand it, eviction should never happen when maxEntries is not reached.

For some of my entities the cache entries are deleted very soon after they where added to the cache. The add was just a query which returns alot of these objects (< 1000). These objects are not changed then (so no invalidation should take place).

So what causes infinispan to delete the objects from the cache?

Thank you

Ickbinet
  • 277
  • 3
  • 12

3 Answers3

2

I suspect that the problem you are having is that pre-Infinispan 7.2.x, eviction was done at segment level, so if the segment size reached it's limit (which is a fraction of maxEntries), then it'd kick of eviction. The problem was solved in Infinispan 7.2.x as explained here. You should try with Infinispan 7.2.x, which should work with Hibernate 4.3.

Galder ZamarreƱo
  • 5,027
  • 2
  • 26
  • 34
1

Yes, Hibernate does not know what is updated in native queries unless you explicitly provide that info, so it clears the entire second level cache to prevent keeping stale data.

To tell Hibernate that the native query does not affect any data in the second level cache:

SQLQuery sqlQuery = session.createSQLQuery(" ... ");
sqlQuery.addSynchronizedQuerySpace("");  
sqlQuery.executeUpdate();
Community
  • 1
  • 1
Dragan Bozanovic
  • 23,102
  • 5
  • 43
  • 110
0

OK; got it...

In Hibernate Query.executeUpdate() clears associated entity cache.

Other ORM's do the same?

Ickbinet
  • 277
  • 3
  • 12