I have a service which calls external system to retrieve some kind of objects by their external id as well as submit them back to update. Rather than retrieving objects one
For me it worked fine with this config. This is a obfuscated version of my code.
@Cacheable(cacheNames = "test", key = "#p0")
public List<String> getTestFunction(List<String> someIds) {
getTestFunction(Arrays.asList("A","B","C"));
2020-04-02 15:12:35.492 TRACE 18040 --- [Test worker] o.s.cache.interceptor.CacheInterceptor : Computed cache key '[A, B, C]' for operation Builder[public java.util.List org.Main.getTestFunction(java.util.List)] caches=[test] | key='#p0' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
You see that it concatinated strings
... Computed cache key '[A, B, C]' ...
My setup: /resources/ehcache.xml
<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
<cache name="test"
maxBytesLocalHeap="1M"
timeToLiveSeconds="300"/>
</ehcache>
gradle.build
plugins {
id "org.springframework.boot" version "2.2.4.RELEASE"
....
}
dependencies {
implementation "org.springframework.boot:spring-boot-starter-cache"
implementation "org.ehcache:ehcache:3.8.1"
...
}
AFAIK this is not possible with annotations. You can use the imperative API, which contains the bulk operations you need, for example Cache.getAll(keySet)
and Cache.removeAll(keySet)