我正在使用Spring Boot @CachePut和@Cacheable注释来缓存数据 .

@CachePut(value = "cache1", key = "#clientId")
public Map<String, Object> buildCache(Long clientId){
Map<String, Object> cacheMap= new HashMap<String, Object>();
//get values from remote db and store them in the local db as well as cache
return cacheMap;
}

@Cacheable(value = "cache1", key = "#clientId")
public Map<String, Object> getFromCache(Long clientId){
     //get from local db
}

在buildCache中,我从远程数据库获取值并将这些值保存在本地数据库和缓存中 . 在getCache方法中,我从本地DB获取值 . 当我第一次调用getCache方法时,它会被执行并且本地数据库值会保存在缓存中 . 然后我调用了buildCache方法来更新缓存以及本地数据库值 . 之后,我再次调用getCache方法来获取更新的值 . 但是这种方法仍然返回旧值而不是新值

简而言之,为了刷新缓存,我执行@CachePut方法 . 但是当我调用@Cacheable方法时,我没有得到更新的值 .

请告诉我哪里出错了 .