33333333333

This commit is contained in:
777
2025-01-22 18:16:36 +08:00
parent e07f27f595
commit 7dc7f874e4

View File

@@ -13,9 +13,11 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -89,15 +91,21 @@ public class SystemConfigManager {
return Long.valueOf(value); return Long.valueOf(value);
} }
private final Map<String,String> CACHE = new ConcurrentHashMap<>();
/** /**
* 获取配置信息 * 获取配置信息
* @param systemConfig * @param systemConfig
* @return * @return
*/ */
public String getSystemConfig(SystemConfigEnum systemConfig){ public String getSystemConfig(SystemConfigEnum systemConfig){
String value = (String) redisTemplate.opsForHash().get(RedisHttpConstant.SYSTEM_CONFIG, systemConfig.name()); String value = CACHE.get(systemConfig.name());
if(StringUtils.isBlank(value)){ if(value == null){
return systemConfig.getDefaultValue(); value = (String) redisTemplate.opsForHash().get(RedisHttpConstant.SYSTEM_CONFIG, systemConfig.name());
if(StringUtils.isBlank(value)){
value = systemConfig.getDefaultValue();
}
CACHE.put(systemConfig.name(), value);
} }
return value; return value;
} }
@@ -155,6 +163,7 @@ public class SystemConfigManager {
sensitiveService.setSensitive(value.equals("1")); sensitiveService.setSensitive(value.equals("1"));
} }
redisTemplate.opsForHash().put(RedisHttpConstant.SYSTEM_CONFIG, key,value); redisTemplate.opsForHash().put(RedisHttpConstant.SYSTEM_CONFIG, key,value);
CACHE.remove(key);
} }
} }