Considering the below service how can I dynamically modify the cache configuration with the /actuator/refresh endpoint
@Service
@Slf4j
public class GreetingService {
@Cacheable("greeting")
public String greet(String name) {
log.info("Greeting: {}", name);
return "Hello " + name ;
}
}
with the following default configuration
spring
cache:
caffeine:
spec: maximumSize=100,expireAfterAccess=600s
Let's say setting to maximumSize=50,expireAfterAccess=300s
Adding @RefreshScope in GreetingService does not work. Somehow I need to instruct Spring Boot to re-create the CacheManager?
I have a supporting project here:
- https://github.com/altfatterz/refreshscope-demo
- https://github.com/altfatterz/refreshscope-demo-config
Thanks.