diff --git a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/login/StandardLoginClient.java b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/login/StandardLoginClient.java index 0712ed7d25..e03290a9f9 100644 --- a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/login/StandardLoginClient.java +++ b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/login/StandardLoginClient.java @@ -39,7 +39,7 @@ public StandardLoginClient(BkLoginApiClient bkLoginApiClient) { } /** - * 获取指定用户信息 + * 根据 token 获取指定用户信息 * * @param bkToken 用户登录 token * @return 用户信息 diff --git a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/TenantLocalCache.java b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/TenantLocalCache.java new file mode 100644 index 0000000000..d981eee3f6 --- /dev/null +++ b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/TenantLocalCache.java @@ -0,0 +1,46 @@ +package com.tencent.bk.job.common.paas.user; + +import com.tencent.bk.job.common.paas.model.OpenApiTenant; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * 租户信息缓存 + */ +public class TenantLocalCache { + + private final UserMgrApiClient userMgrApiClient; + + private ScheduledThreadPoolExecutor refresher = new ScheduledThreadPoolExecutor(1); + + + private final Map tenantCache = new HashMap<>(); + + private volatile boolean initialed = false; + + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + + + public TenantLocalCache(UserMgrApiClient userMgrApiClient) { + this.userMgrApiClient = userMgrApiClient; +// refresher.scheduleAtFixedRate(this::loadCache, ) + } + + public OpenApiTenant get(String tenantId) { + if (!initialed) { + loadCache(); + initialed = true; + } + return null; + } + + private void loadCache() { + + } +}