mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-21 02:25:56 +08:00
Pre Merge pull request !484 from Mercurialx/dev
This commit is contained in:
commit
d5f1c4a802
@ -39,7 +39,7 @@ public class OssFactory {
|
|||||||
/**
|
/**
|
||||||
* 根据类型获取实例
|
* 根据类型获取实例
|
||||||
*/
|
*/
|
||||||
public static synchronized OssClient instance(String configKey) {
|
public static OssClient instance(String configKey) {
|
||||||
String json = CacheUtils.get(CacheNames.SYS_OSS_CONFIG, configKey);
|
String json = CacheUtils.get(CacheNames.SYS_OSS_CONFIG, configKey);
|
||||||
if (json == null) {
|
if (json == null) {
|
||||||
throw new OssException("系统异常, '" + configKey + "'配置信息不存在!");
|
throw new OssException("系统异常, '" + configKey + "'配置信息不存在!");
|
||||||
@ -47,19 +47,18 @@ public class OssFactory {
|
|||||||
OssProperties properties = JsonUtils.parseObject(json, OssProperties.class);
|
OssProperties properties = JsonUtils.parseObject(json, OssProperties.class);
|
||||||
// 使用租户标识避免多个租户相同key实例覆盖
|
// 使用租户标识避免多个租户相同key实例覆盖
|
||||||
String key = properties.getTenantId() + ":" + configKey;
|
String key = properties.getTenantId() + ":" + configKey;
|
||||||
OssClient client = CLIENT_CACHE.get(key);
|
return CLIENT_CACHE.compute(key, (k, client) -> {
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
CLIENT_CACHE.put(key, new OssClient(configKey, properties));
|
|
||||||
log.info("创建OSS实例 key => {}", configKey);
|
log.info("创建OSS实例 key => {}", configKey);
|
||||||
return CLIENT_CACHE.get(key);
|
return new OssClient(configKey, properties);
|
||||||
}
|
}
|
||||||
// 配置不相同则重新构建
|
|
||||||
if (!client.checkPropertiesSame(properties)) {
|
if (!client.checkPropertiesSame(properties)) {
|
||||||
CLIENT_CACHE.put(key, new OssClient(configKey, properties));
|
// 配置不相同则重新构建
|
||||||
log.info("重载OSS实例 key => {}", configKey);
|
log.info("重载OSS实例 key => {}", configKey);
|
||||||
return CLIENT_CACHE.get(key);
|
return new OssClient(configKey, properties);
|
||||||
}
|
}
|
||||||
return client;
|
return client;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user