From ae20662de93bae4c222543e4061800156704eaaa Mon Sep 17 00:00:00 2001 From: wangqing <408564126@qq.com> Date: Thu, 8 Feb 2024 17:31:44 +0800 Subject: [PATCH] fix: set redis expire for journal list --- .../java/com/luoo/music/controller/JournalController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/luoo_music/src/main/java/com/luoo/music/controller/JournalController.java b/luoo_music/src/main/java/com/luoo/music/controller/JournalController.java index fe37a82..03aa41d 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/JournalController.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/JournalController.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import com.luoo.music.dao.CommentDao; @@ -111,7 +112,7 @@ public class JournalController { if(null==journalRespDTOs) { List pageList = journalService.queryPage(queryReq); journalRespDTOs = pageList.stream().map(journal -> JournalMapper.getJournalRespDTO(journal, journalCollectSet,mongoTemplate,redisTemplate,commentDao)).collect(Collectors.toList()); - redisTemplate.opsForValue().set(redisPageJournalResponseDtoKey,journalRespDTOs); + redisTemplate.opsForValue().set(redisPageJournalResponseDtoKey,journalRespDTOs,6, TimeUnit.HOURS); } return journalRespDTOs; } @@ -119,7 +120,7 @@ public class JournalController { Set set=(Set) redisTemplate.opsForValue().get(Constants.REDIS_KEY_USER_COLLECT_JOURNAL+userId); if(null==set) { set=userCollectInfoService.getCollectSet(userId, CollectTypeEnum.JOURNAL); - redisTemplate.opsForValue().set(Constants.REDIS_KEY_USER_COLLECT_JOURNAL+userId,set); + redisTemplate.opsForValue().set(Constants.REDIS_KEY_USER_COLLECT_JOURNAL+userId,set,6,TimeUnit.HOURS); } return set; }