在我的项目中,我们使用ehcache进行二级缓存,我们还提到了<defaultCache>标记和一些<cache>属性。
ehcache.xml样品
<ehcache>
<defaultCache
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
maxEntriesLocalDisk="10000000"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
<cache name="com.test.First"
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
/>
<cache name="com.test.Second"
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
/>
</ehcache>hibernate.cfg.xml样品
<class-cache class="com.test.First" usage="read-only"/>
<class-cache class="com.test.Second" usage="read-only"/>
<class-cache class="com.test.Third" usage="read-only"/>在这里,我们为com.test.Third添加了com.test.Third标记,这在ehcache.xml文件中没有提到。
这个com.test.Third类也会使用defaultCache进行缓存吗?
发布于 2014-05-28 14:57:09
实际上,这种情况下是这样的,因为Hibernate将为您完成工作。但是,automatically.不是为创建缓存defaultCache而设计的。有关更多细节,请查看这个问题:Do caches in ehcache.xml inherit from defaultCache?和这个问题:EhCache default cache in java
https://stackoverflow.com/questions/21652059
复制相似问题