Essentially, I have a few applications that will interact with the data layer independently. For each instance that is running, caching needs will likely be different. I know you can easily define different cacheManagers as an @Bean within its own class, such as:
@Bean
public CaffeineCache cacheA() {
return new CaffeineCache("CACHE_A",
Caffeine.newBuilder()
.expireAfterAccess(1, TimeUnit.DAYS)
.build());
}
@Bean
public CaffeineCache cacheB() {
return new CaffeineCache("CACHE_B",
Caffeine.newBuilder()
.expireAfterWrite(7, TimeUnit.DAYS)
.recordStats()
.build());
}
however, we're not necessarily wanting the code to recompile each time; therefore, it would be great if we could configure this as the application.properties level, as this is how the applications will interact.
I know with caffeine you can define some caches like so:
spring.cache.type=caffeine
spring.cache.cache-names=cache-a,cache-b
spring.cache.caffeine.spec=maximumSize=100, expireAfterWrite=1d
But to my understanding, the specs will be applied to every cache. My question is how do I apply different specs to each individual cache name at the application.properties level?
Thanks.