Skip to content

Commit

Permalink
Merge pull request #11381 from carlyin0801/issue_11380_env_atom_logo_fix
Browse files Browse the repository at this point in the history
bug:多环境情况下流水线编辑页面插件logo缓存优化 #11380
  • Loading branch information
mingshewhe authored Jan 8, 2025
2 parents d3a9e31 + b7b7746 commit 71a1e56
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@ package com.tencent.devops.store.atom.service.impl

import com.fasterxml.jackson.core.type.TypeReference
import com.github.benmanes.caffeine.cache.Caffeine
import com.tencent.devops.common.api.auth.REFERER
import com.tencent.devops.common.api.constant.CommonMessageCode
import com.tencent.devops.common.api.exception.ErrorCodeException
import com.tencent.devops.common.api.util.JsonUtil
import com.tencent.devops.common.api.util.ThreadLocalUtil
import com.tencent.devops.common.util.RegexUtils
import com.tencent.devops.common.web.utils.BkApiUtil
import com.tencent.devops.common.web.utils.I18nUtil
import com.tencent.devops.model.store.tables.TAtom
import com.tencent.devops.store.atom.dao.AtomDao
import com.tencent.devops.store.atom.dao.AtomPropDao
import com.tencent.devops.store.pojo.atom.AtomProp
import com.tencent.devops.store.atom.service.AtomPropService
import com.tencent.devops.store.common.service.StoreI18nMessageService
import com.tencent.devops.store.common.service.action.StoreDecorateFactory
import com.tencent.devops.store.common.utils.StoreUtils
import com.tencent.devops.store.pojo.atom.AtomProp
import com.tencent.devops.store.pojo.atom.enums.AtomStatusEnum
import com.tencent.devops.store.pojo.common.ATOM_OUTPUT
import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum
Expand Down Expand Up @@ -81,8 +84,10 @@ class AtomPropServiceImpl @Autowired constructor(
var atomPropMap: MutableMap<String, AtomProp>? = null
// 从缓存中查找插件属性信息
var queryDbAtomCodes: MutableList<String>? = null
val referer = BkApiUtil.getHttpServletRequest()?.getHeader(REFERER) ?: ThreadLocalUtil.get(REFERER)?.toString()
val refererHost = referer?.let { RegexUtils.splitDomainContextPath("$referer/")?.first } ?: ""
atomCodes.forEach { atomCode ->
val atomProp = atomPropCache.getIfPresent(atomCode)
val atomProp = atomPropCache.getIfPresent("$refererHost:$atomCode")
if (atomProp != null) {
if (atomPropMap == null) {
atomPropMap = mutableMapOf()
Expand Down Expand Up @@ -124,7 +129,7 @@ class AtomPropServiceImpl @Autowired constructor(
)
atomPropMap!![atomCode] = atomProp
// 把数据放入缓存
atomPropCache.put(atomCode, atomProp)
atomPropCache.put("$refererHost:$atomCode", atomProp)
}
}
return atomPropMap
Expand Down

0 comments on commit 71a1e56

Please sign in to comment.