fix: CacheKeyGenerator fix

dev
gitea-관리자 1 year ago
parent d55c3302e1
commit cbfeeac158

@ -109,6 +109,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
* @return
* </pre>
*/
@Transactional
@Override
public TokenRevokeResponse revokeToken(final NiceCiRequest reqDTO){
TokenRevokeResponse resDTO = niceCiService.revokeToken(reqDTO);

@ -1,14 +1,17 @@
package kr.xit.core.spring.config.cache;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.cache.interceptor.SimpleKeyGenerator;
import java.lang.reflect.Method;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.cache.interceptor.SimpleKey;
/**
* <pre>
* 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
@ -19,6 +22,7 @@ import java.lang.reflect.Method;
* 2023-09-06 limju
*
* </pre>
*
* @see CacheType
* @see CachingConfig
*/
@ -26,9 +30,22 @@ public class CacheKeyGenerator implements KeyGenerator {
@Override
public Object generate(Object target, Method method, Object... params) {
final StringBuilder keyBuilder = new StringBuilder();
keyBuilder.append(method.getName());
keyBuilder.append(SimpleKeyGenerator.generateKey(params));
return keyBuilder.toString();
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;
}
}

Loading…
Cancel
Save