I need to cache the result of a method that call a webservice. The method signature is like this :
public Result search(long id, String name, Date date);
and the result depends on all the parameters
I created the ehcache configuration for the cache myCache
, normally to use this cache I should use the @CacheResult
annotation :
@CacheResult(cacheName = "myCache")
public Result search(long id, String name, Date date);
But in my case I need to call a static method on the date
parameter, I want to do it the same way as the @Cacheable
annotation :
@Cacheable(value = "myCache", key ="{#id, #name, T(my.static).method(#date)}")
public Result search(long id, String name, Date date);
My question is how could I call a static method on a parameter while using @CacheResult
?
@CacheResult
supplies a way to customize the generated key by defining a key generator class like this:It does not support definition of key generation in terms of SpEL evaluation directly in the annotation; instead you must provide your own implementation of
javax.cache.annotation.CacheKeyGenerator
: