Such a simple task:
Create a method cache so that a given method is only executed once per day, and further requests return the cached result.
Since I won’t pollute my method with caching code, I would like some “aspect-oriented” solution, so all I would have to do is annotate my method ("@Cacheable” or such).
The current project setup includes Ehcache and the Spring Framework, so that’s a piece of cake…
…or maybe it isn’t? Let’s check the alternatives:
- Spring annotation-based caching is only available since Spring 3.1, which is not released yet (we are currently using version 3.0.5)
- The former Spring-Modules project did include this feature, but it is dead for years and only works with Spring 2.x
- Ehcache recommends the Ehcache-Spring-Annotations project, which requires Ehcache 2.x - but we are currently using version 1.5 (which is bundled with the current Hibernate release)
So it seems that there is no out-of-the-box solution for our configuration :-(
The only remaining option is
- do it yourself, like e.g. this guy