有人能否证实使用 ehcache 扩展的 grails 缓存插件是否可以设置 TTL 设置,例如 timeToLiveSeconds?
基础插件文档明确声明不支持 TTL,但 ehcache 扩展提到了这些值。到目前为止,我尝试设置缓存的 TTL 值没有成功:
grails.cache.config = {
cache {
name 'messages'
maxElementsInMemory 1000
eternal false
timeToLiveSeconds 120
overflowToDisk false
memoryStoreEvictionPolicy 'LRU'
}
}
@Cacheable('messages')
def getMessages()
然而,这些消息将无限期地缓存。我可以使用@CacheEvict注释手动清空缓存,但我希望在使用ehcache扩展时支持TTL。谢谢。