更改缓存后如何返回当前数据列表?

时间:2019-05-03 16:44:03

标签: java spring caching

在对缓存数据进行任何操作之后,我没有在所有实体的返回列表中得到实际值(方法getAllProxyConfigurations)。 为什么会发生这种情况以及如何解决?

   @Cacheable("configuration")
    public List<MySomeConfiguration> getAllProxyConfigurations() {
        return repository.getAllConfigurations();
}

   @Cacheable(value = "configuration", key = "#root.target.getConfigurationById(#id).serverId")
    public MySomeConfiguration getConfigurationById(Long id) {
...
   return configuration;
}

 @CachePut(value = "configuration", key = "#configuration.serverId", condition = "#result.id != null")
    public MySomeConfiguration addOrUpdateConfiguration(Configuration configuration) {
   return configuration;
}

   @Cacheable(value = "configuration", key = "#serverId")
    public MySomeConfiguration getConfigurationByServerId(String serverId) {...
   return configuration;
}

   @CacheEvict(value = "configuration", key = "#root.target.getConfigurationById(#id).serverId")
    public void deleteConfigurationById(Long id) {
...
}

0 个答案:

没有答案