From b47b648343ca2a01037481b6cdc667f06ed733b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Mon, 27 Nov 2023 10:03:23 +0900 Subject: [PATCH] [FEAT] cache external api --- .../twtw/backend/domain/path/controller/PathController.java | 3 +++ .../twtw/backend/domain/place/controller/PlaceController.java | 2 ++ .../twtw/backend/domain/plan/controller/PlanController.java | 2 ++ 3 files changed, 7 insertions(+) diff --git a/backend/src/main/java/com/twtw/backend/domain/path/controller/PathController.java b/backend/src/main/java/com/twtw/backend/domain/path/controller/PathController.java index 2320e8f4..7f4e78b1 100644 --- a/backend/src/main/java/com/twtw/backend/domain/path/controller/PathController.java +++ b/backend/src/main/java/com/twtw/backend/domain/path/controller/PathController.java @@ -8,6 +8,7 @@ import jakarta.validation.Valid; +import org.springframework.cache.annotation.Cacheable; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -21,12 +22,14 @@ public PathController(PathService pathService) { } @PostMapping("/search/car") + @Cacheable(value = "carPath", key = "{#request}", cacheManager = "cacheManager", unless = "result.body.code != 0") public ResponseEntity searchCarPath( @RequestBody @Valid SearchCarPathRequest request) { return ResponseEntity.ok(pathService.searchCarPath(request)); } @PostMapping("/search/ped") + @Cacheable(value = "pedPath", key = "{#request}", cacheManager = "cacheManager", unless = "result.body.features.size() <= 0") public ResponseEntity searchPedPath( @RequestBody @Valid SearchPedPathRequest request) { return ResponseEntity.ok(pathService.searchPedPath(request)); diff --git a/backend/src/main/java/com/twtw/backend/domain/place/controller/PlaceController.java b/backend/src/main/java/com/twtw/backend/domain/place/controller/PlaceController.java index d6956b35..2a356ab2 100644 --- a/backend/src/main/java/com/twtw/backend/domain/place/controller/PlaceController.java +++ b/backend/src/main/java/com/twtw/backend/domain/place/controller/PlaceController.java @@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor; +import org.springframework.cache.annotation.Cacheable; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; @@ -19,6 +20,7 @@ public class PlaceController { private final PlaceService placeService; @GetMapping("surround") + @Cacheable(value = "surroundPlace", key = "{#surroundPlaceRequest}", cacheManager = "cacheManager", unless = "result.body.results.size() <= 0") public ResponseEntity searchSurroundPlace( @ModelAttribute final SurroundPlaceRequest surroundPlaceRequest) { return ResponseEntity.ok(placeService.searchSurroundPlace(surroundPlaceRequest)); diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/controller/PlanController.java b/backend/src/main/java/com/twtw/backend/domain/plan/controller/PlanController.java index 9cbed27d..23330142 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/controller/PlanController.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/controller/PlanController.java @@ -10,6 +10,7 @@ import lombok.RequiredArgsConstructor; +import org.springframework.cache.annotation.Cacheable; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -22,6 +23,7 @@ public class PlanController { private final PlanService planService; @GetMapping("search/destination") + @Cacheable(value = "planDestination", key = "{#request}", cacheManager = "cacheManager", unless = "result.body.results.size() <= 0") public ResponseEntity searchPlanDestination( @ModelAttribute final SearchDestinationRequest request) { return ResponseEntity.ok(planService.searchPlanDestination(request));