2
votes

I have a domain class in grails 1.5 that represents data from a table that seldom changes. How can I configure hibernate's cache so the class accesses the table let's say only once per hour?

Thanks

1

1 Answers

1
votes

Drop an ehcache.xml into grails-app/conf. You can take one, for instance, from %grails_home%/lib/ehcache-core-XXX.jar, ehcache-failsafe.xml.

In defaultCache tag, put in timeToLiveSeconds="3600".

Though, cache won't give you an absolute guarantee - for instance, it won't pre-cache, and some instances can be pushed out.

EDIT: In case you're interested in per-class caching strategy, a sample:

<cache name="org.appfuse.model.User"
    eternal="false"
    timeToIdleSeconds="3600"
    timeToLiveSeconds="3600"
    overflowToDisk="false" />