Skip to content

Commit aa11228

Browse files
authored
Merge pull request #99 from Dalguring/feature/add-cache-evict
feature: cache evict 추가
2 parents f9de5df + 1943473 commit aa11228

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/main/java/com/rentify/rentify_api/rental/service/RentalService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.time.temporal.ChronoUnit;
2121
import java.util.List;
2222
import lombok.RequiredArgsConstructor;
23+
import org.springframework.cache.annotation.CacheEvict;
2324
import org.springframework.data.domain.Page;
2425
import org.springframework.data.domain.Pageable;
2526
import org.springframework.stereotype.Service;
@@ -34,6 +35,7 @@ public class RentalService {
3435
private final UserRepository userRepository;
3536
private final PostRepository postRepository;
3637

38+
@CacheEvict(value = "posts", key = "#request.postId")
3739
@Transactional
3840
public RentalResponse createRental(Long userId, RentalRequest request) {
3941
// 사용자 조회
@@ -150,6 +152,7 @@ private static RentalResponse convertToResponse(Rental rental) {
150152
.build();
151153
}
152154

155+
@CacheEvict(value = "posts", key = "#result.postId")
153156
@Transactional
154157
public RentalResponse cancelRental(Long userId, Long rentalId) {
155158
// 대여 정보 조회

0 commit comments

Comments
 (0)