关于 java:infinispan hibernate cache eviction | 珊瑚贝

infinispan hibernate cache eviction


我正在使用 Infinispan 6.0.0 和 Hibernate 4.3.6。

我的配置是:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    <!– 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>

系统属性未设置,因此应用默认值 (10.000, -1)。

据我了解,当未达到 maxEntries 时,永远不会发生驱逐。

对于我的一些实体,缓存条目在添加到缓存后很快就会被删除。添加只是一个返回大量这些对象(< 1000)的查询。这些对象不会更改(因此不会发生失效)。

那么是什么原因导致 infinispan 从缓存中删除对象呢?

谢谢


我怀疑您遇到的问题是 Infinispan 7.2.x 之前的版本,驱逐是在段级别完成的,所以如果段大小达到它的限制(这是 maxEntries 的一小部分),那么它就会启动驱逐。如here所述,该问题已在 Infinispan 7.2.x 中解决。您应该尝试使用 Infinispan 7.2.x,它应该适用于 Hibernate 4.3。


是的,Hibernate 不知道本地查询中更新了什么,除非您明确提供该信息,因此它会清除整个二级缓存以防止保留过时的数据。

告诉Hibernate本机查询不影响二级缓存中的任何数据:

1
2
3
SQLQuery sqlQuery = session.createSQLQuery(” …”);
sqlQuery.addSynchronizedQuerySpace(“”);  
sqlQuery.executeUpdate();

好的;明白了……

在 Hibernate Query.executeUpdate() 中清除关联的实体缓存。

其他 ORM 也一样吗?


来源:https://www.codenong.com/32011933/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_8855.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?