Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9150563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:37:40+00:00 2026-06-17T11:37:40+00:00

Can anyone confirm if TTL settings e.g. timeToLiveSeconds can be set using the grails

  • 0

Can anyone confirm if TTL settings e.g. timeToLiveSeconds can be set using the grails cache plugin with the ehcache extension?

The documentation for the base plugin explicitly states that TTL is not supported, but the ehcache extension mentions these values. So far I’ve had no success setting TTL values for my cache:

grails.cache.config = {
    cache {
        name 'messages'
        maxElementsInMemory 1000
        eternal false
        timeToLiveSeconds 120
        overflowToDisk false
        memoryStoreEvictionPolicy 'LRU'
    }
}

@Cacheable('messages')
def getMessages()

However the messages remain cached indefinitely. I can manually flush the cache using the @CacheEvict annotation but I was hoping that TTL would be supported when using the ehcache extension.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:37:41+00:00Added an answer on June 17, 2026 at 11:37 am

    Yes, the cache-ehcache plugin definitely supports TTL and all of the cache configuration properties that are natively supported by EhCache. As stated in the doc, the base cache plugin implements a simple in-memory cache that does not support TTL, but the Cache DSL will pass through any unknown configuration settings to the underlying cache provider.

    You can configure the EhCache settings by adding the following to Config.groovy or CacheConfig.groovy:

    grails.cache.config = {
        cache {
            name 'mycache'
        }
    
        //this is not a cache, it's a set of default configs to apply to other caches
        defaults {
            eternal false
            overflowToDisk true
            maxElementsInMemory 10000
            maxElementsOnDisk 10000000
            timeToLiveSeconds 300
            timeToIdleSeconds 0
        }
    }
    

    You can verify the cache settings at runtime as follows:

    grailsCacheManager.cacheNames.each { 
       def config = grailsCacheManager.getCache(it).nativeCache.cacheConfiguration
       println "timeToLiveSeconds: ${config.timeToLiveSeconds}"
       println "timeToIdleSeconds: ${config.timeToIdleSeconds}"
    }
    

    See the EhCache javadoc for CacheConfiguration for the other cache properties. You can also enable detailed debug logging of caching by logging grails.plugin.cache and net.sf.ehcache.

    Note that the Grails caching plugins implement their own cache manager which is different and separate from the native EhCache cache manager. If you have configured EhCache directly (using ehcache.xml or other means) then these caches will run separately from the caches managed by the Grails plugin.

    Note: There was indeed a bug in older versions of the Cache-EhCache plugin where the TTL setting was not being set correctly and objects were expiring in a year; this was fixed in Grails-Cache-Ehcache 1.1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone confirm that using a persistent outgoing TCP connection on port 80 will
Can anyone confirm or deny that it is possible to set an IP address
Can anyone confirm the default options I should be using for compiler optimisation. I
Can anyone confirm if I am using MVVM (2 way binding) then I don't
When adding objects to an NSArray using initWithObjects can anyone confirm for me that
Can anyone confirm that after changing the Apple Push Certificate to follow the new
Can anyone confirm if there's an access 2003 runtime available to allow users to
My Get confirm isn't triggering the query? Can anyone see what I'm doing wrong?
Can anyone confirm if the latest release of Apache httpClient 4.0.1 or 4.1 alpha2
Can anyone confirm what the standard says about the default return type of vararg

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.