From d2efb1164a4ccb0117d2a71b08aa294898ecba4a Mon Sep 17 00:00:00 2001 From: dltjdgh0428 Date: Mon, 8 Apr 2024 16:52:15 +0900 Subject: [PATCH] =?UTF-8?q?feature=20:=20=EC=A2=8B=EC=95=84=EC=9A=94=20Red?= =?UTF-8?q?is=20=EC=BA=90=EC=8B=B1=EC=B2=98=EB=A6=AC=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/book_everywhere/BookEverywhereApplication.java | 2 ++ .../com/book_everywhere/auth/config/SecurityConfig.java | 3 ++- .../likes/service/LikesCachingServiceImpl.java | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/book_everywhere/BookEverywhereApplication.java b/src/main/java/com/book_everywhere/BookEverywhereApplication.java index f56f07f..0b5d79f 100644 --- a/src/main/java/com/book_everywhere/BookEverywhereApplication.java +++ b/src/main/java/com/book_everywhere/BookEverywhereApplication.java @@ -2,7 +2,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cache.annotation.EnableCaching; +@EnableCaching @SpringBootApplication public class BookEverywhereApplication { public static void main(String[] args) { diff --git a/src/main/java/com/book_everywhere/auth/config/SecurityConfig.java b/src/main/java/com/book_everywhere/auth/config/SecurityConfig.java index aa8501a..250d9e4 100644 --- a/src/main/java/com/book_everywhere/auth/config/SecurityConfig.java +++ b/src/main/java/com/book_everywhere/auth/config/SecurityConfig.java @@ -65,10 +65,11 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .requestMatchers("/").permitAll() // 테스트 관련 url .requestMatchers("/health", "/env", "/test/**", "/swagger-ui/**").permitAll() + .requestMatchers("/api/reviews").permitAll() // 비회원도 볼수있는 url .requestMatchers("/api/review", "/api/map", "/api/tags", "/api/data/**").permitAll() // 나머지 - .requestMatchers("/api/**").hasAuthority("ROLE_MEMBER") +// .requestMatchers("/api/**").hasAuthority("ROLE_MEMBER") .anyRequest().authenticated() ) .oauth2Login(oauth2Login -> diff --git a/src/main/java/com/book_everywhere/likes/service/LikesCachingServiceImpl.java b/src/main/java/com/book_everywhere/likes/service/LikesCachingServiceImpl.java index 9820e91..99f8b9d 100644 --- a/src/main/java/com/book_everywhere/likes/service/LikesCachingServiceImpl.java +++ b/src/main/java/com/book_everywhere/likes/service/LikesCachingServiceImpl.java @@ -2,19 +2,24 @@ import com.book_everywhere.likes.repository.LikesRepository; import lombok.RequiredArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CachePut; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class LikesCachingServiceImpl implements LikesCachingService { + private static final Logger logger = LoggerFactory.getLogger(LikesCachingServiceImpl.class); private final LikesRepository likesRepository; @Override - @CachePut(value = "likesCount", key = "#reviewId") + @Cacheable(value = "likesCount", key = "#reviewId") public Long 좋아요캐시업데이트(Long reviewId) { + logger.info(reviewId+"의 캐시가 없데이트 되었습니다."); return likesRepository.countByReviewId(reviewId); }