提问人:asayke 提问时间:11/8/2023 最后编辑:asayke 更新时间:11/8/2023 访问量:25
@CachePut后,@Cacheable对象在缓存中丢失
@Cacheable object is lost in cache after @CachePut
问:
@GetMapping("/{id}")
@Cacheable(value = "guests", key = "#id")
@RolesAllowed({"MANAGER", "ADMIN"})
public ResponseEntity<GuestResponse> findById(@PathVariable("id") Long id) {
return ResponseEntity.ok(guestService.findById(id));
}
@CachePut(value = "guests", key = "#id")
@PutMapping("/{id}")
@RolesAllowed({"MANAGER", "ADMIN"})
public ResponseEntity<HttpStatus> update(@RequestBody Map<Object, Object> fields, @PathVariable("id") Long id) {
guestService.update(id, fields);
return ResponseEntity.ok(HttpStatus.OK);
}
对象通常按 id 缓存,但@CachePut后,尽管数据库中发生了更改,但无法再从缓存中找到该对象。作为回应,我得到了 200 个没有尸体。
答: 暂无答案
下一个:过期时数据库中的咖啡因缓存更新值
评论
HttpStatus
GuestResponse