【发布时间】:2014-03-05 15:00:45
【问题描述】:
使用 Grails 2.2.3 并尝试通过 DSL 配置缓存,如 here 和 here 所述。
说明指出可以在 Config.groovy 或 CacheConfig.groovy 文件中进行配置。 这必须在 Config.groovy 的 grails.cache.config 键下或在 CacheConfig.groovy 的键 config 下。
我不想缓存 gorm 操作。休眠完全关闭。需要缓存一些 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 错误还是我遗漏了什么?
【问题讨论】: