grails 1.3.9 应用程序中 ehcache 的默认值是什么?我特别对查询缓存值感兴趣;我通过 postgres 的 psql 删除了几行,但我没有看到我的应用程序中反映的更改。我还没有将 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 是一个直写式缓存。它只会缓存通过 hibernate 及其二级缓存操作的对象。如果你在数据库中编写sql查询,它不会在你的缓存中缓存对象。
要更深入地了解它,请看一下here and here.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)