File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
src/main/java/com/linglevel/api/streak/service Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,18 @@ public class ReadingSessionService {
2323
2424 public void startReadingSession (String userId , ContentType contentType , String contentId ) {
2525 String key = READING_SESSION_KEY_PREFIX + userId + READING_SESSION_KEY_SUFFIX ;
26+ ReadingSession existingSession = getReadingSession (userId );
27+
28+ // 같은 작품에 대한 세션이 이미 존재하면 started 시간을 갱신하지 않음
29+ if (existingSession != null
30+ && existingSession .getContentType ().equals (contentType )
31+ && existingSession .getContentId ().equals (contentId )) {
32+ // TTL만 갱신
33+ redisTemplate .expire (key , READING_SESSION_TTL );
34+ return ;
35+ }
36+
37+ // 다른 작품이거나 세션이 없으면 새로운 세션 생성
2638 ReadingSession session = ReadingSession .builder ()
2739 .contentType (contentType )
2840 .contentId (contentId )
You can’t perform that action at this time.
0 commit comments