I put together a brief road map page: http://code.google.com/p/ehcache-spr...s/wiki/RoadMap
What you want to do can be done with a custom CacheKeyGenerator [1] implementation. While the framework will provide your key generator with a reference to the MethodInvocation there is no reason you have to use it. Assuming your example is date based a simple key generator like:
Code:
package com.example;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.aopalliance.intercept.MethodInvocation;
import com.googlecode.ehcache.annotations.key.CacheKeyGenerator;
public class DateCacheKeyGenerator implements CacheKeyGenerator<Serializable> {
private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
@Override
public Serializable generateKey(MethodInvocation methodInvocation) {
return this.generateKey((Object)methodInvocation);
}
@Override
public Serializable generateKey(Object... data) {
final Date now = new Date();
synchronized (this.dateFormat) {
return dateFormat.format(now);
}
}
}
Then reference this generator in your annotation:
Code:
@Cacheable(cacheName="exampleCache",
keyGenerator = @KeyGenerator (name = "com.example.DateCacheKeyGenerator")
)
public ExampleData getData(String arg1, Object arg2);
Now while that should be a functional key generator (I didn't actually test it) it could be improved on a by doing things like using a Timer to generate the date string once per minute and storing it in a volatile field instead of generating the date string every time the cached method is requested.
[1] http://ehcache-spring-annotations.go...Generator.html