我试图在我的应用程序中使用Ehcache和Spring 3.1内置缓存注释(@Cacheable,@CacheEvict和@CachePut)来实现缓存。Spring的@CachePut注释是否可以使用void返回类型?
我创建了一个高速缓存如下:
@Cacheable(value = "userCache", key = "#user.id")
public List<User> getAllUsers() {
...
}
我试图更新此缓存使用,如下@CachePut注释的新值:
@CachePut(value = "userCache", key = "#user.id")
public void addUser(User user) {
...
}
然而,新的“用户“未被添加到缓存中。这是因为void返回类型吗?