Skip to content

Commit

Permalink
카마스터 조회에 캐시 적용 (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjddhh authored Aug 25, 2023
2 parents c7219d4 + 0d6269b commit 809513f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import java.util.List;
import java.util.stream.Collectors;

import org.hibernate.annotations.Cache;
import org.springframework.cache.annotation.Cacheable;

import lombok.RequiredArgsConstructor;
import softeer.be_my_car_master.application.car_master.dto.response.GetCarMasterResponse;
import softeer.be_my_car_master.domain.agency.Agency;
Expand All @@ -15,6 +18,7 @@ public class GetCarMasterUseCase {

private final GetCarMastersPort port;

@Cacheable(value = "redis", key = "#latitude + '_' + #longitude", unless = "#result == null")
public GetCarMasterResponse execute(Double latitude, Double longitude) {
List<Agency> agencies = port.findAgenciesByLocation(latitude, longitude);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public RedisCacheManagerBuilderCustomizer redisCacheManagerBuilderCustomizer() {
.withCacheConfiguration("redis",
RedisCacheConfiguration.defaultCacheConfig()
.computePrefixWith(cacheName -> "prefix::" + cacheName + "::")
.entryTtl(Duration.ofSeconds(10))
.entryTtl(Duration.ofSeconds(15))
.disableCachingNullValues()
.serializeKeysWith(
RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())
Expand Down

0 comments on commit 809513f

Please sign in to comment.