Skip to content

Commit

Permalink
✨ Feat: API 응답 캐시 해제
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnsugyeong committed Jul 21, 2024
1 parent 6c827a4 commit f8a8f94
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
import com.example.briefingapi.security.handler.annotation.AuthMember;
import com.example.briefingcommon.common.presentation.response.CommonResponse;
import com.example.briefingcommon.entity.Member;
import jakarta.validation.Valid;

import org.springdoc.core.annotations.ParameterObject;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;


import com.example.briefingapi.annotation.CacheEvictByBriefingId;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "03-Briefing \uD83D\uDCF0", description = "브리핑 관련 API")
@RestController
Expand All @@ -44,7 +46,7 @@ public CommonResponse<BriefingResponseDTO.BriefingDetailDTO> findBriefing(
return CommonResponse.onSuccess(briefingService.findBriefing(id, member));
}

@CacheEvict(value = "findBriefingsV2", key = "#request.getBriefingType()")
// @CacheEvict(value = "findBriefingsV2", key = "#request.getBriefingType()")
@PostMapping("/briefings")
@ResponseStatus(HttpStatus.CREATED)
@Operation(summary = "03-03Briefing \uD83D\uDCF0 브리핑 등록", description = "")
Expand All @@ -62,7 +64,7 @@ public void createBriefing(@RequestBody final BriefingRequestDTO.BriefingCreate
* @param id, BriefingResponseDTO.BriefingUpdateDTO
* @return 수정된 값, 요청으로 온 값과 동일
*/
@CacheEvictByBriefingId(value = "findBriefingsV2", briefingId = "#id")
// @CacheEvictByBriefingId(value = "findBriefingsV2", briefingId = "#id")
@Operation(summary = "03-04Briefing \uD83D\uDCF0 브리핑 내용 수정", description = "")
@Parameter(name = "id", description = "브리핑 아이디", example = "1")
@PatchMapping("/briefings/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
import com.example.briefingapi.security.handler.annotation.AuthMember;
import com.example.briefingcommon.common.presentation.response.CommonResponse;
import com.example.briefingcommon.entity.Member;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "03-Briefing V2 \uD83D\uDCF0", description = "브리핑 관련 API V2")
@RestController
Expand All @@ -24,7 +26,7 @@ public class BriefingV2Api {

@GetMapping("/briefings")
@Operation(summary = "03-01Briefing \uD83D\uDCF0 브리핑 목록 조회 V2", description = "")
@Cacheable(value = "findBriefingsV2", key = "#params.getType()")
// @Cacheable(value = "findBriefingsV2", key = "#params.getType()")
public CommonResponse<BriefingResponseDTO.BriefingPreviewListDTOV2> findBriefingsV2(
@ParameterObject @ModelAttribute BriefingRequestParam.BriefingPreviewListParam params) {
return CommonResponse.onSuccess(briefingV2Service.findBriefings(params));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
package com.example.briefingapi.scrap.presentation;
import java.util.List;

import com.example.briefingapi.scrap.business.ScrapV2Service;
import com.example.briefingapi.scrap.presentation.dto.ScrapRequest;
import com.example.briefingapi.scrap.presentation.dto.ScrapResponse;
import com.example.briefingcommon.common.presentation.response.CommonResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.web.bind.annotation.*;

import com.example.briefingapi.annotation.CacheEvictByBriefingId;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "05-Scrap V2 📁", description = "스크랩 관련 API V2")
@RestController
Expand All @@ -23,7 +27,7 @@
public class ScrapV2Api {
private final ScrapV2Service scrapV2Service;

@CacheEvictByBriefingId(value = "findBriefingsV2", briefingId = "#request.getBriefingId()")
// @CacheEvictByBriefingId(value = "findBriefingsV2", briefingId = "#request.getBriefingId()")
@Operation(summary = "05-01 Scrap📁 스크랩하기 V2", description = "브리핑을 스크랩하는 API입니다.")
@PostMapping("/scraps/briefings")
@ApiResponses({
Expand All @@ -50,7 +54,7 @@ public CommonResponse<ScrapResponse.CreateDTOV2> createV2(
return CommonResponse.onSuccess(scrapV2Service.create(request));
}

@CacheEvictByBriefingId(value = "findBriefingsV2", briefingId = "#briefingId")
// @CacheEvictByBriefingId(value = "findBriefingsV2", briefingId = "#briefingId")
@Operation(summary = "05-02 Scrap📁 스크랩 취소 V2", description = "스크랩을 취소하는 API입니다.")
@DeleteMapping("/scraps/briefings/{briefingId}/members/{memberId}")
@ApiResponses({
Expand Down

0 comments on commit f8a8f94

Please sign in to comment.