Spring引导后构造方法缓存值更新

时间:2018-05-28 02:05:37

标签: spring spring-boot

在我的微服务spring启动应用程序中,我使用了@PostConstruct注释来初始化和缓存一些数据,如下所示,

  @Microservice
  @EnableRetry
  @EnableCaching
  public class OrderMicroService {
public static void main(final String[] args) {
    SpringApplication.run(OrderMicroService.class, args);
}

@Bean
public CacheManager cacheManager() {
    return new ConcurrentMapCacheManager("ServiceCode");
}
  }

我的@Postconstruct方法如下,

@Service
 public class ServiceCodeImpl implements ServiceCode {
   @PostConstruct
  public void populateMap(){
  private static HashMap<String,Orders.Service> serviceCache=new HashMap<String,Services.Service>();

// Rest call here to get some xml from other interface and caching here

  serviceCache.put(put something here);

   }
 }

他们是否可以自动和手动更新缓存数据[因为从其他界面获取的.xml文件可能会在某个时间修改但不经常更新]。在我需要更新我的缓存的任何更改。

0 个答案:

没有答案