【发布时间】:2021-10-30 20:52:48
【问题描述】:
@CachePut(value = "dishDTOs", key = "IDOFTHERETURNEDVALUE")
@CacheEvict(cacheNames = "dishDTOList", allEntries = true)
public DishResponseDTO createDish(DishCreationDTO dishCreationDTO) {
int restaurantId = dishCreationDTO.getRestaurantId();
var restaurant = restaurantRepository.getById(restaurantId);
var dish = DishMapper.toDish(dishCreationDTO, restaurant);
return toDishResponseDTO(dishRepository.save(dish));
}
ID 由数据库分配,因此我需要以某种方式将其作为键。
【问题讨论】: