fun.fengwk.convention4j.springboot.starter.cache.registry.DefaultCacheable Maven / Gradle / Ivy
The newest version!
package fun.fengwk.convention4j.springboot.starter.cache.registry;
import fun.fengwk.convention4j.common.cache.Cacheable;
import fun.fengwk.convention4j.common.cache.exception.CacheExecuteException;
import fun.fengwk.convention4j.common.util.Pair;
import fun.fengwk.convention4j.springboot.starter.cache.annotation.meta.ListenKeyMeta;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Method;
import java.util.*;
import java.util.function.Function;
/**
* @author fengwk
*/
@Slf4j
public class DefaultCacheable implements Cacheable {
private final Method method;
private final String cacheVersion;
private final List defaultListenKeyList;
public DefaultCacheable(Method method, String cacheVersion, List defaultListenKeyList) {
this.method = Objects.requireNonNull(method, "method cannot be null");
this.cacheVersion = Objects.requireNonNull(cacheVersion, "cacheVersion cannot be null");
this.defaultListenKeyList = Objects.requireNonNull(defaultListenKeyList, "defaultListenKeyList cannot be null");
}
@Override
public String getCacheName() {
return method.toString();
}
@Override
public String getCacheVersion() {
return cacheVersion;
}
@Override
public List> extractListenKeyGroupListFromParams(Object[] params) {
// 收集所有被@ListenKey注释的参数或内部字段
int listValueSizeCheck = -1;
Map valueMap = new HashMap<>();
for (DefaultListenKey defaultListenKey : defaultListenKeyList) {
Function