2012-11-12 39 views
0

什麼我使用休眠4.1.1.FinalSpring MVC的3.1.X並同時使用第一和第二級緩存。我使用註釋爲高速緩存操作配置了我的域對象。但緩存不會在磁盤上存儲任何內容。休眠4.1.x版的Ehcache不存儲在磁盤上

這是我的ehcache.xml中的文件:

<?xml version="1.0" encoding="UTF-8"?> 
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"> 

    <!-- 
    <diskStore path="java.io.tmpdir"/> 
    --> 
    <diskStore path="java.io.tmpdir/ehcache"/> 
    <defaultCache 
     maxElementsInMemory="10000" 
     eternal="false" 
     timeToIdleSeconds="300" 
     timeToLiveSeconds="120" 
     overflowToDisk="true" 
     maxElementsOnDisk="10000000" 
     diskPersistent="true" 
     diskExpiryThreadIntervalSeconds="120" 
     memoryStoreEvictionPolicy="LRU" 
    /> 
</ehcache> 

Hibernate緩存屬性:

<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop> 
<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml</prop> 
<prop key="hibernate.cache.use_query_cache">true</prop> 
<prop key="hibernate.cache.use_second_level_cache">true</prop> 

基於Annonation配置爲域對象:

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) 

號命名的文件夾**的Ehcache/tmp文件夾中:**

/tmp folder

回答

1

的Ehcache將存儲上只有當它保存在maxElementsInMemory內存本身的對象數量的磁盤對象。你確定這麼多的對象真的被緩存了,因爲只有在這之後,EhCache纔會開始在磁盤上存儲對象。