【问题标题】:Hibernate 4.1.x EhCache doesn't store anything on diskHibernate 4.1.x EhCache 不在磁盘上存储任何内容
【发布时间】:2012-11-01 00:28:27
【问题描述】:

我使用 Hibernate 4.1.1.FinalSpring MVC 3.1.x 并同时使用 一级和二级缓存。我使用注释为缓存操作配置了我的域对象。但是缓存不会在磁盘上存储任何内容。

这是我的 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>

休眠缓存属性:

<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>

域对象的基于注解的配置:

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)

/tmp文件夹中没有名为**ehcache的文件夹:**

【问题讨论】:

    标签: hibernate caching spring-mvc ehcache nhibernate-caches


    【解决方案1】:

    EhCache 只有在内存中保存了maxElementsInMemory 个对象时才会将对象存储到磁盘上。你确定这么多对象真的被缓存了吗,因为只有在这之后,EhCache 才会开始在磁盘上存储对象。

    【讨论】:

      猜你喜欢
      • 2012-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-13
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多