2012-08-05 22 views
1

grails 1.3.9應用程序中的ehcache默認值是什麼?特別是我對查詢緩存值感興趣;我通過postgres的psql刪除了幾行,並沒有看到我的應用程序中反映的更改。我沒有將ehcache.xml文件添加到conf目錄。我甚至重新啓動了Grails應用程序,數據仍然顯示在報告中。是否有任何緩存文件可以作爲解決方法刪除?Grails 1.3.9應用程序中的EHCache默認值

更新:我添加了以下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」 不工作要麼。

+1

Ehcache用作直寫式高速緩存。如果您通過psql直接刪除行,緩存無法知道它。我希望緩存保持不變。 – GreyBeardedGeek 2012-08-05 05:36:33

回答

1

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