【问题标题】:grails 3 cache - ehcache configurationgrails 3 缓存 - ehcache 配置
【发布时间】:2018-05-05 04:03:56
【问题描述】:

我使用 Grails 3.1.8。 如何设置 timeToLiveSeconds 属性?

插件配置suggests me设置:

grails.cache.config = {
   cache {
      …
   }
   defaultCache {
      maxElementsInMemory 10000
      eternal false
      timeToIdleSeconds 120
      timeToLiveSeconds 120
      overflowToDisk true
      maxElementsOnDisk 10000000
      diskPersistent false
      diskExpiryThreadIntervalSeconds 120
      memoryStoreEvictionPolicy 'LRU'
   }
}

但这对我不起作用。如何设置默认和自定义属性?

【问题讨论】:

    标签: grails ehcache grails-3.1


    【解决方案1】:

    您链接的同一文档在您从中提取该配置示例之前和之后的部分中包含该信息。

    Caches 部分中,对于每个缓存配置元素:

    grails.cache.config = {
        cache {
            name 'mycache'
            eternal false
            overflowToDisk true
            maxElementsInMemory 10000
            maxElementsOnDisk 10000000
        }
    }
    

    而在默认缓存和缓存默认值的后半部分,对于默认值:

    grails.cache.config = {
        cache {
            …
        }
        defaults {
            maxElementsInMemory 1000
            eternal false
            overflowToDisk false
            maxElementsOnDisk 0
        }
    }
    

    它们都将接受timeToLiveSeconds 属性的设置,因为它们只是示例,并不表示配置仅限于一组受限属性。

    【讨论】:

      【解决方案2】:

      根据grails-cache-ehcache github,您需要Grails 3 插件的version 3,根据它的docs,现在只支持XML configuration

      你可以在issue#37找到一个例子。

      【讨论】:

        猜你喜欢
        • 2016-06-27
        • 1970-01-01
        • 1970-01-01
        • 2016-04-23
        • 1970-01-01
        • 2014-08-23
        • 2013-04-23
        • 2015-05-02
        • 2012-03-13
        相关资源
        最近更新 更多