【问题标题】:Grails ehcache plugin cache not expiringGrails ehcache插件缓存不会过期
【发布时间】:2013-04-23 11:45:20
【问题描述】:

使用 Grails ehcache plugin 我正在尝试缓存响应并偶尔刷新该响应。

这就是我的 Config.groovy 中的内容,

grails.cache.config = {
    cache {
        name 'winners'
        eternal false
        timeToLiveSeconds 10
    }
}

我用@Cacheable('winners') 注释了获胜者端点。

我看到响应被缓存了,但我从来没有看到缓存过期。有人知道这里可能发生了什么吗?

【问题讨论】:

标签: caching grails configuration ehcache


【解决方案1】:

我遇到了同样的问题。

ehcache.xml 文件添加到配置目录似乎可以解决它。

详情请见http://ehcache.org/documentation/integrations/grails

顺便说一句,我不得不将属性“maxEntriesLocalHeap”替换为“maxElementsInMemory”。

【讨论】:

  • 老实说,我已经从我最初的问题继续前进,我无法测试你的答案。在某个时候,我可能会重新审视 Grails 缓存,但在此之前,我会接受一个投票,因为我是唯一一个回答这个问题的人。
【解决方案2】:

我认为这是由与 Grails 缓存插件相关的错误引起的,它不遵守 EhCache 的 TTL 设置(仅适用于控制器操作响应)。我无法解决这个错误,不得不创建一个单独的 Quartz 作业来定期刷新缓存。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-01
    相关资源
    最近更新 更多