Grails DSL配置被忽略

时间:2014-03-05 15:00:46

标签: grails ehcache

使用Grails 2.2.3并尝试按照文档herehere通过DSL配置缓存。

说明指出配置可以在Config.groovy或CacheConfig.groovy文件中完成。 这必须在Config.groovy的 grails.cache.config 键下或在CacheConfig.groovy的 config 下。

我不是要尝试缓存gorm操作。 Hybernate完全关闭。需要缓存一些REST结果的方法,结果证明是昂贵的,并且可以使用缓存......

我尝试了两个选项,此警告表示未读取配置:

WARN : net.sf.ehcache.config.ConfigurationFactory: No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/home/myhome/.grails/ivy-cache/net.sf.ehcache/ehcache-core/jars/ehcache-core-2.4.6.jar!/ehcache-failsafe.xml

我正在使用CacheConfig.groovy

中的此配置进行测试
config = {
    cache {
        name 'someName'
        //Overwrite these, inherit rest
        timeToIdleSeconds 86400 //I like 24hours
        timeToLiveSeconds 86400
    }
    defaultCache {
        //Just inherit from defaults
    }
    defaults {
        timeToIdleSeconds 120
        timeToLiveSeconds 120
        eternal false
        overflowToDisk false
        maxElementsInMemory 10000
        maxElementsOnDisk 10000000
        memoryStoreEvictionPolicy="LRU"
    }
}

这可能是一个grails-cache-plugin错误,还是我遗漏了什么?

1 个答案:

答案 0 :(得分:2)

该警告适用于Hibernate二级缓存中使用的Ehcache。它说在类路径中没有ehcache.xml(或在其他地方显式配置),所以它会回到jar文件中的默认xml文件。这与用于cache-ehcache插件的Ehcache配置是分开的。

相关问题