From 25a9870f713a559ab2e3d404ec5d9a7dcf7e5789 Mon Sep 17 00:00:00 2001 From: kanguk Date: Tue, 15 Oct 2024 02:35:32 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20previewPlan=20TTL=EC=9D=84=20=EC=A0=9C?= =?UTF-8?q?=EB=8C=80=EB=A1=9C=20=EC=A0=81=EC=9A=A9=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EC=9D=80=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TTL이 제대로 설정되어있지 않던 문제를 수정한다. --- .../com/splanet/splanet/previewplan/entity/PlanCard.java | 4 ++-- .../com/splanet/splanet/previewplan/entity/PlanGroup.java | 4 ++-- .../com/splanet/splanet/previewplan/entity/PreviewPlan.java | 6 ++++-- .../splanet/previewplan/service/PreviewPlanService.java | 4 ++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/splanet/splanet/previewplan/entity/PlanCard.java b/src/main/java/com/splanet/splanet/previewplan/entity/PlanCard.java index 43f3f28d..54121a5f 100644 --- a/src/main/java/com/splanet/splanet/previewplan/entity/PlanCard.java +++ b/src/main/java/com/splanet/splanet/previewplan/entity/PlanCard.java @@ -29,8 +29,8 @@ public class PlanCard { private String startDate; private String endDate; - @TimeToLive(unit = TimeUnit.HOURS) - private Long expiration = 1L; + @TimeToLive + private Long expiration; public static String generateId() { return UUID.randomUUID().toString().split("-")[0]; diff --git a/src/main/java/com/splanet/splanet/previewplan/entity/PlanGroup.java b/src/main/java/com/splanet/splanet/previewplan/entity/PlanGroup.java index abf99d59..7708647b 100644 --- a/src/main/java/com/splanet/splanet/previewplan/entity/PlanGroup.java +++ b/src/main/java/com/splanet/splanet/previewplan/entity/PlanGroup.java @@ -25,6 +25,6 @@ public class PlanGroup { private String groupId; private Set planCardIds; - @TimeToLive(unit = TimeUnit.HOURS) - private Long expiration = 1L; + @TimeToLive + private Long expiration; } diff --git a/src/main/java/com/splanet/splanet/previewplan/entity/PreviewPlan.java b/src/main/java/com/splanet/splanet/previewplan/entity/PreviewPlan.java index 5665bbb4..f88525cd 100644 --- a/src/main/java/com/splanet/splanet/previewplan/entity/PreviewPlan.java +++ b/src/main/java/com/splanet/splanet/previewplan/entity/PreviewPlan.java @@ -1,6 +1,7 @@ package com.splanet.splanet.previewplan.entity; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import org.springframework.data.annotation.Id; @@ -13,6 +14,7 @@ @Getter @NoArgsConstructor @AllArgsConstructor +@Builder @RedisHash("previewPlan") public class PreviewPlan { @@ -21,6 +23,6 @@ public class PreviewPlan { private List groupIds; - @TimeToLive(unit = TimeUnit.HOURS) - private Long expiration = 1L; + @TimeToLive + private Long expiration; } diff --git a/src/main/java/com/splanet/splanet/previewplan/service/PreviewPlanService.java b/src/main/java/com/splanet/splanet/previewplan/service/PreviewPlanService.java index e8daaa8e..485767d4 100644 --- a/src/main/java/com/splanet/splanet/previewplan/service/PreviewPlanService.java +++ b/src/main/java/com/splanet/splanet/previewplan/service/PreviewPlanService.java @@ -24,6 +24,7 @@ @RequiredArgsConstructor public class PreviewPlanService { + private static final long EXPIRATION_TIME = 3600L; private static final String PLAN_GROUP_PREFIX = "planGroup:"; private static final String PLAN_CARD_PREFIX = "planCard:"; private static final int PLAN_CARD_PREFIX_LENGTH = PLAN_CARD_PREFIX.length(); @@ -94,6 +95,7 @@ private PlanCard buildPlanCard(String customKey, String deviceId, String groupId .description(planCardRequestDto.description()) .startDate(planCardRequestDto.startDate()) .endDate(planCardRequestDto.endDate()) + .expiration(EXPIRATION_TIME) .build(); } @@ -101,9 +103,11 @@ private void updatePlanGroup(String deviceId, String groupId, String cardId, boo String groupKey = generateGroupKey(deviceId, groupId); PlanGroup planGroup = planGroupRepository.findById(groupKey) .orElse(PlanGroup.builder() + .customKey(groupKey) .deviceId(deviceId) .groupId(groupId) .planCardIds(new HashSet<>()) + .expiration(EXPIRATION_TIME) .build()); if (add) {