feat: add redis
This commit is contained in:
@@ -5,7 +5,6 @@ import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.ChangeDetectionCoreService;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@@ -35,7 +34,6 @@ public class ChangeDetectionService {
|
||||
return changeDetectionCoreService.getChangeDetectionYearList();
|
||||
}
|
||||
|
||||
@Cacheable(value = "changeDetectionPolygon", key = "#analUid + '_' + #mapSheetNum")
|
||||
public ChangeDetectionDto.PolygonFeatureList getChangeDetectionPolygonList(
|
||||
Long analUid, String mapSheetNum) {
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.kamco.cd.kamcoback.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator;
|
||||
import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import java.time.Duration;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -46,6 +49,9 @@ public class RedisConfig {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.registerModule(new JavaTimeModule());
|
||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
objectMapper.findAndRegisterModules();
|
||||
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
@@ -71,8 +77,24 @@ public class RedisConfig {
|
||||
// 기본 레디스 캐시 세팅
|
||||
@Bean
|
||||
public CacheManager cacheManager(RedisConnectionFactory connectionFactory) {
|
||||
ObjectMapper cacheObjectMapper = new ObjectMapper();
|
||||
cacheObjectMapper.registerModule(new JavaTimeModule());
|
||||
cacheObjectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
cacheObjectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
cacheObjectMapper.findAndRegisterModules();
|
||||
|
||||
// 타입 정보 포함 - JAVA_LANG_OBJECT로 제한적으로 적용
|
||||
PolymorphicTypeValidator ptv =
|
||||
BasicPolymorphicTypeValidator.builder()
|
||||
.allowIfSubType("com.kamco.cd.kamcoback")
|
||||
.allowIfSubType("org.springframework.data.domain")
|
||||
.allowIfSubType("java.util")
|
||||
.allowIfSubType("java.time")
|
||||
.build();
|
||||
cacheObjectMapper.activateDefaultTyping(ptv, ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT);
|
||||
|
||||
GenericJackson2JsonRedisSerializer serializer =
|
||||
new GenericJackson2JsonRedisSerializer(redisObjectMapper());
|
||||
new GenericJackson2JsonRedisSerializer(cacheObjectMapper);
|
||||
|
||||
RedisCacheConfiguration config =
|
||||
RedisCacheConfiguration.defaultCacheConfig()
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -67,11 +66,6 @@ public class InferenceResultService {
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(
|
||||
value = "inferenceResultWithGeom",
|
||||
key =
|
||||
"#id + '_' + #searchReq.page + '_' + #searchReq.size + '_' + (#searchReq.sort != null ? #searchReq.sort : 'none') + '_' + (#searchReq.targetClass != null ? #searchReq.targetClass : 'none') + '_' + (#searchReq.compareClass != null ? #searchReq.compareClass : 'none') + '_' + (#searchReq.mapSheetNum != null ? #searchReq.mapSheetNum.toString() : 'none')",
|
||||
unless = "#result == null || #result.isEmpty()")
|
||||
public Page<InferenceResultDto.DetailListEntity> listInferenceResultWithGeom(
|
||||
@NotNull Long id, InferenceResultDto.SearchGeoReq searchReq) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user