diff --git a/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java b/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java index 42838ff..e1289f4 100644 --- a/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java +++ b/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java @@ -6,7 +6,6 @@ import kr.xit.biz.cmm.mapper.ICmmEnsCacheMapper; import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO; import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo; -import kr.xit.core.spring.config.cache.CacheKeyGenerator; import kr.xit.core.spring.config.cache.CacheType; import kr.xit.core.spring.config.cache.CachingConfig; import lombok.RequiredArgsConstructor; @@ -34,8 +33,8 @@ import org.springframework.transaction.annotation.Transactional; * * * @see CacheType - * @see CacheKeyGenerator * @see CachingConfig + * @see org.springframework.cache.interceptor.SimpleKeyGenerator */ @Slf4j @RequiredArgsConstructor @@ -50,7 +49,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { * @return CrtfInfo */ @Transactional(readOnly = true) - @Cacheable(cacheNames = "niceCiInfo", keyGenerator = "cacheKeyGenerator") + @Cacheable(cacheNames = "niceCiInfo", keyGenerator = "simpleKeyGenerator") public NiceCiInfo getNiceCiInfoCache(final String signguCode, final String ffnlgCode) { return cmmEnsMapper.selectNiceCiInfo(signguCode, ffnlgCode); } @@ -61,7 +60,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { * @param ffnlgCode */ @Transactional(readOnly = true) - @CacheEvict(cacheNames = "niceCiInfo", keyGenerator = "cacheKeyGenerator") + @CacheEvict(cacheNames = "niceCiInfo", keyGenerator = "simpleKeyGenerator") public void removeNiceCiInfoCache(final String signguCode, final String ffnlgCode) { } @@ -72,7 +71,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { * @return CmmEnsRlaybsnmDTO */ @Transactional(readOnly = true) - @Cacheable(cacheNames = "rlaybsnmInfo", keyGenerator = "cacheKeyGenerator") + @Cacheable(cacheNames = "rlaybsnmInfo", keyGenerator = "simpleKeyGenerator") public CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final CmmEnsRequestDTO dto) { return cmmEnsMapper.selectEnsRlaybsnmInfo(dto); } @@ -83,7 +82,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { * @param ffnlgCode */ @Transactional(readOnly = true) - @CacheEvict(cacheNames = "rlaybsnmInfo", keyGenerator = "cacheKeyGenerator") + @CacheEvict(cacheNames = "rlaybsnmInfo", keyGenerator = "simpleKeyGenerator") public void removeRlaybsnmInfoCache(final CmmEnsRequestDTO dto) { } diff --git a/mens-batch/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java b/mens-batch/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java index 2f89fa0..8b7e714 100644 --- a/mens-batch/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java +++ b/mens-batch/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java @@ -5,7 +5,6 @@ import com.github.benmanes.caffeine.cache.stats.CacheStats; import kr.xit.biz.cmm.mapper.ICmmEnsCacheMapper; import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo; -import kr.xit.core.spring.config.cache.CacheKeyGenerator; import kr.xit.core.spring.config.cache.CacheType; import kr.xit.core.spring.config.cache.CachingConfig; import lombok.RequiredArgsConstructor; @@ -50,7 +49,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { * @return CrtfInfo */ @Transactional(readOnly = true) - @Cacheable(cacheNames = "niceCiInfo", keyGenerator = "cacheKeyGenerator") + @Cacheable(cacheNames = "niceCiInfo", keyGenerator = "simpleKeyGenerator") public NiceCiInfo getNiceCiInfoCache(final String signguCode, final String ffnlgCode) { return cmmEnsMapper.selectNiceCiInfo(NiceCiInfo.builder() .signguCode(signguCode) @@ -64,7 +63,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { * @param ffnlgCode */ @Transactional(readOnly = true) - @CacheEvict(cacheNames = "niceCiInfo", keyGenerator = "cacheKeyGenerator") + @CacheEvict(cacheNames = "niceCiInfo", keyGenerator = "simpleKeyGenerator") public void removeNiceCiInfoCache(final String signguCode, final String ffnlgCode) { } @@ -75,7 +74,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { * @return CmmEnsRlaybsnmDTO */ @Transactional(readOnly = true) - @Cacheable(cacheNames = "rlaybsnmInfo", keyGenerator = "cacheKeyGenerator") + @Cacheable(cacheNames = "rlaybsnmInfo", keyGenerator = "simpleKeyGenerator") public CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final String signguCode, final String ffnlgCode) { return cmmEnsMapper.selectEnsRlaybsnmInfo( CmmEnsRlaybsnmDTO.builder() @@ -91,7 +90,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { * @param ffnlgCode */ @Transactional(readOnly = true) - @CacheEvict(cacheNames = "rlaybsnmInfo", keyGenerator = "cacheKeyGenerator") + @CacheEvict(cacheNames = "rlaybsnmInfo", keyGenerator = "simpleKeyGenerator") public void removeRlaybsnmInfoCache(final String signguCode, final String ffnlgCode) { } diff --git a/mens-core/src/main/java/kr/xit/core/spring/config/cache/CacheKeyGenerator.java b/mens-core/src/main/java/kr/xit/core/spring/config/cache/CacheKeyGenerator.java deleted file mode 100644 index b9e9471..0000000 --- a/mens-core/src/main/java/kr/xit/core/spring/config/cache/CacheKeyGenerator.java +++ /dev/null @@ -1,51 +0,0 @@ -package kr.xit.core.spring.config.cache; - -import java.lang.reflect.Method; -import org.springframework.cache.interceptor.KeyGenerator; -import org.springframework.cache.interceptor.SimpleKey; - -/** - *
- * description : Cache key Generator - * -> cache method parmeter -> key로 Generator - * - params가 String... 형태인 경우 - method(String arg1, String arg2) - * -> arg1="", arg2="" 형태로 생성 - * - params가 Object class 인 경우 - method(DTO class) - * -> [필드값, 필드값] 형태로 생성 - * packageName : kr.xit.core.spring.config.cache - * fileName : CacheKeyGenerator - * author : limju - * date : 2023-09-06 - * ====================================================================== - * 변경일 변경자 변경 내용 - * ---------------------------------------------------------------------- - * 2023-09-06 limju 최초 생성 - * - *- * - * @see CacheType - * @see CachingConfig - */ -public class CacheKeyGenerator implements KeyGenerator { - - @Override - public Object generate(Object target, Method method, Object... params) { - if(params.length == 0) { - return SimpleKey.EMPTY; - } - - // params가 String... 형태인 경우: method(String arg1, String arg2) - // -> arg1="", arg2="" 형태로 생성 - if(params.length == 1) { - Object param = params[0]; - if(param != null && !param.getClass().isArray()) { - return param; - } - } - - // params가 Object 인 경우: method(DTO class) - // -> [필드값, 필드값] 형태로 생성 - SimpleKey simpleKey = new SimpleKey(params); - return simpleKey; - } -} diff --git a/mens-core/src/main/java/kr/xit/core/spring/config/cache/CacheType.java b/mens-core/src/main/java/kr/xit/core/spring/config/cache/CacheType.java index d5f76db..e4f51f7 100644 --- a/mens-core/src/main/java/kr/xit/core/spring/config/cache/CacheType.java +++ b/mens-core/src/main/java/kr/xit/core/spring/config/cache/CacheType.java @@ -2,6 +2,7 @@ package kr.xit.core.spring.config.cache; import lombok.AllArgsConstructor; import lombok.Getter; +import org.springframework.cache.interceptor.SimpleKeyGenerator; /** *
@@ -17,7 +18,7 @@ import lombok.Getter; * 2023-09-06 limju 최초 생성 * *- * @see CacheKeyGenerator + * @see SimpleKeyGenerator * @see CachingConfig */ @Getter diff --git a/mens-core/src/main/java/kr/xit/core/spring/config/cache/CachingConfig.java b/mens-core/src/main/java/kr/xit/core/spring/config/cache/CachingConfig.java index afd3bb5..59c3026 100644 --- a/mens-core/src/main/java/kr/xit/core/spring/config/cache/CachingConfig.java +++ b/mens-core/src/main/java/kr/xit/core/spring/config/cache/CachingConfig.java @@ -7,6 +7,7 @@ import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.caffeine.CaffeineCache; import org.springframework.cache.interceptor.KeyGenerator; +import org.springframework.cache.interceptor.SimpleKeyGenerator; import org.springframework.cache.support.SimpleCacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -30,7 +31,7 @@ import java.util.stream.Collectors; * * * @see CacheType - * @see CacheKeyGenerator + * @see SimpleKeyGenerator */ @Slf4j @EnableCaching @@ -75,7 +76,7 @@ public class CachingConfig { } @Bean - public KeyGenerator cacheKeyGenerator() { - return new CacheKeyGenerator(); + public KeyGenerator simpleKeyGenerator() { + return new SimpleKeyGenerator(); } }