hibernate - Grails 1.3.9应用程序中的EHCache默认值

标签 hibernate grails ehcache default-value

grails 1.3.9应用程序中ehcache的默认值是什么?我特别对查询缓存值感兴趣;我通过postgres的psql删除了几行,但看不到我的应用程序反射(reflect)的更改。我尚未将ehcache.xml文件添加到conf目录中。我什至重新启动了grails应用程序,数据仍然显示在报告中。没有任何可以作为解决方法删除的缓存文件吗?

更新:我添加了以下ehcache.xml配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<diskStore path="/tmp/ehcache_t2"/>
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
   maxElementsInMemory="10000"
   eternal="false"
   timeToLiveSeconds="120">

</defaultCache>
<cache name="org.hibernate.cache.UpdateTimestampsCache"
  maxElementsInMemory="10000"
  timeToIdleSeconds="300"
   />
<cache name="org.hibernate.cache.StandardQueryCache"
  maxElementsInMemory="10000"
  timeToIdleSeconds="30"
   />
</ehcache>

但是StandardQueryCache的timeToIdleSeconds =“30”也不起作用。

最佳答案

Grails将在conf目录中查找ehcache.xml。如果找不到,它将使用您的类路径中的那个,看一看ehcache-core.jar。您会看到一个名为 ehcache-failsafe.xml 的文件,您将在其中找到:

<defaultCache
            maxElementsInMemory="10000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            maxElementsOnDisk="10000000"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU"
            /> 

要使用查询缓存,必须在Datasource.groovy中进行配置:
hibernate {
    cache.use_second_level_cache=true
    cache.use_query_cache=true
    cache.provider_class='org.hibernate.cache.EhCacheProvider'
}

尽管,就像@GreyBeardedGeek指出的那样,EhCache是​​直写式缓存。它只会缓存通过休眠及其二级缓存处理的对象。如果在数据库中编写一个sql查询,它将不会在高速缓存中高速缓存对象。

要更深入地了解它,请看看herehere

关于hibernate - Grails 1.3.9应用程序中的EHCache默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11813489/

相关文章:

JSF 形式的 Hibernate POJO

grails - 左联接grails标准

java - Jersey :找不到类的语法元素

java - 如何读写EhCache中的记录?

java - 将 Hibernate Entity 转换为清理 POJO 以进行序列化

java - Hibernate 不会自己创建 Join Table

javascript - 如何使用angular js在Grails/asset管道中 “cache bust” html文件

java - Tomcat 7 停止响应

java - 选择具有复合 id 的对象时的 Hibernate 查询缓存

java - 你将如何处理 spring web 应用程序的 TDD