代码之家  ›  专栏  ›  技术社区  ›  Zoltan Altfatter

spring云配置刷新缓存配置

  •  1
  • Zoltan Altfatter  · 技术社区  · 6 年前

    考虑到下面的服务,如何使用 /执行器/刷新

    @Service
    @Slf4j
    public class GreetingService {
    
        @Cacheable("greeting")
        public String greet(String name) {
           log.info("Greeting: {}", name);
           return "Hello " + name ;
        }
    }
    

    使用以下默认配置

    spring
      cache:
        caffeine:
          spec: maximumSize=100,expireAfterAccess=600s
    

    maximumSize=50,expireAfterAccess=300s

    添加 @刷新镜 在里面 不起作用。不知怎么的,我需要指示springboot重新创建CacheManager?

    1. https://github.com/altfatterz/refreshscope-demo
    2. https://github.com/altfatterz/refreshscope-demo-config

    谢谢。

    1 回复  |  直到 6 年前
        1
  •  0
  •   bilak    6 年前

    你用的是执行器,所以你可能也有 cache actuator curl 'http://server:port/actuator/caches/greeting' -i -X DELETE

    注意:我没有测试过,这只是一个想法