You've already forked FrameTour-BE
fix(repository): 修复人脸缓存获取逻辑
- 添加空值检查避免解析空字符串 - 提取缓存键避免重复格式化 - 优化缓存命中时的对象转换逻辑
This commit is contained in:
@@ -30,7 +30,11 @@ public class FaceRepository {
|
|||||||
|
|
||||||
public FaceEntity getFace(Long id) {
|
public FaceEntity getFace(Long id) {
|
||||||
if (redisTemplate.hasKey(String.format(FACE_CACHE_KEY, id))) {
|
if (redisTemplate.hasKey(String.format(FACE_CACHE_KEY, id))) {
|
||||||
return JacksonUtil.parseObject(redisTemplate.opsForValue().get(String.format(FACE_CACHE_KEY, id)), FaceEntity.class);
|
String json = redisTemplate.opsForValue().get(String.format(FACE_CACHE_KEY, id));
|
||||||
|
if (json == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return JacksonUtil.parseObject(json, FaceEntity.class);
|
||||||
}
|
}
|
||||||
FaceEntity face = faceMapper.get(id);
|
FaceEntity face = faceMapper.get(id);
|
||||||
if (face != null) {
|
if (face != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user