|
@@ -2,7 +2,6 @@ package com.usky.common.tenant.core.service;
|
|
|
|
|
|
import com.google.common.cache.CacheLoader;
|
|
|
import com.google.common.cache.LoadingCache;
|
|
|
-import com.usky.common.core.bean.ApiResult;
|
|
|
import com.usky.common.core.util.CacheUtils;
|
|
|
import com.usky.system.RemoteTenantService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -25,11 +24,11 @@ public class TenantFrameworkServiceImpl implements TenantFrameworkService {
|
|
|
/**
|
|
|
* 针对 {@link #getTenantIds()} 的缓存
|
|
|
*/
|
|
|
- private final LoadingCache<Object, ApiResult<List<Integer>>> getTenantIdsCache = CacheUtils.buildAsyncReloadingCache(
|
|
|
+ private final LoadingCache<Object, List<Integer>> getTenantIdsCache = CacheUtils.buildAsyncReloadingCache(
|
|
|
Duration.ofMinutes(1L), // 过期时间 1 分钟
|
|
|
- new CacheLoader<Object, ApiResult<List<Integer>>>() {
|
|
|
+ new CacheLoader<Object, List<Integer>>() {
|
|
|
@Override
|
|
|
- public ApiResult<List<Integer>> load(Object key) {
|
|
|
+ public List<Integer> load(Object key) {
|
|
|
return remoteTenantService.getTenantIds();
|
|
|
}
|
|
|
});
|
|
@@ -37,12 +36,12 @@ public class TenantFrameworkServiceImpl implements TenantFrameworkService {
|
|
|
/**
|
|
|
* 针对校验结果的缓存
|
|
|
*/
|
|
|
- private final LoadingCache<Integer, ApiResult<Void>> validTenantCache = CacheUtils.buildAsyncReloadingCache(
|
|
|
+ private final LoadingCache<Integer, Boolean> validTenantCache = CacheUtils.buildAsyncReloadingCache(
|
|
|
Duration.ofMinutes(1L), // 过期时间 1 分钟
|
|
|
- new CacheLoader<Integer, ApiResult<Void>>() {
|
|
|
+ new CacheLoader<Integer, Boolean>() {
|
|
|
|
|
|
@Override
|
|
|
- public ApiResult<Void> load(Integer id) {
|
|
|
+ public Boolean load(Integer id) {
|
|
|
return remoteTenantService.validTenant(id);
|
|
|
}
|
|
|
|
|
@@ -50,12 +49,12 @@ public class TenantFrameworkServiceImpl implements TenantFrameworkService {
|
|
|
|
|
|
@Override
|
|
|
@SneakyThrows
|
|
|
- public ApiResult<List<Integer>> getTenantIds() {
|
|
|
+ public List<Integer> getTenantIds() {
|
|
|
return getTenantIdsCache.get(Boolean.TRUE);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ApiResult<Void> validTenant(Integer id) {
|
|
|
+ public Boolean validTenant(Integer id) {
|
|
|
return validTenantCache.getUnchecked(id);
|
|
|
}
|
|
|
|