@Cachable on methods without input parameters?
You can use two cache with different name:
@Bean
public ConcurrentMapCache cache() {
return new ConcurrentMapCache(CACHE_API, CACHE_URL);
}
@Cacheable(CACHE_API)
public String getApi() {
return "api";
}
@Cacheable(CACHE_URL)
public String getUrl() {
return "url";
}
Try this
@Cacheable(value = CACHE, key = "#root.method.name")
Or even
@Cacheable(value = CACHE, key = "#root.methodName")
You need to tell spring to use method name as key. You can use SPEL for this. Here is the doc with various other options.