1

I use Grails 3.1.8. How can I set timeToLiveSeconds property?

plugin configuration suggests me to set:

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

But that does not work for me. How can I set default and custom properties?

Aleksey Kozel
  • 319
  • 1
  • 9
  • 16

2 Answers2

0

The same document you link contains that information in the sections just before and after the ones you extracted that config sample from.

In the Caches section, for per cache config elements:

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

And in the second half of Default cache and cache defaults, for defaults:

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

which will both accept the setting of timeToLiveSeconds property, as they are just examples and not an indication of configuration being limited to a restricted set of properties.

Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43
0

According to grails-cache-ehcache github you need version 3 of the plugin for Grails 3 and according to it's docs only XML configuration is supported now.

You can find an example in issue#37.

verglor
  • 616
  • 7
  • 21