javaspringcachingehcacheoscache

How do I set an cache time for objects in OSCache using spring-modules?


I have an application in need of some caching, and for some of the semi-static data, I want them to stay in the cache a maximum amount of time (for instance 10 minutes) before being refreshed. My system merely retrieves data, never updates it, so I have no idea of when to flush the cache using the property. In the OSCache docs, such an expiry time can be set both using the programmatic API and the configuration for the taglib, but the spring-modules documentation is silent on the matter.

Does anyone know if/how this can be done?


Solution

  • I figured it out. The answer is hidden in ehcache's own configuration file. By setting the property "timeToLiveSeconds" to for instance "600", the element in the cache will expire after ten minutes.