mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 08:13:44 +08:00 
			
		
		
		
	update 优化 TenantSpringCacheManager 处理逻辑
This commit is contained in:
		@@ -1,5 +1,7 @@
 | 
			
		||||
package org.dromara.common.tenant.manager;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.dromara.common.core.constant.GlobalConstants;
 | 
			
		||||
import org.dromara.common.core.utils.StringUtils;
 | 
			
		||||
import org.dromara.common.redis.manager.PlusSpringCacheManager;
 | 
			
		||||
@@ -11,6 +13,7 @@ import org.springframework.cache.Cache;
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@Slf4j
 | 
			
		||||
public class TenantSpringCacheManager extends PlusSpringCacheManager {
 | 
			
		||||
 | 
			
		||||
    public TenantSpringCacheManager() {
 | 
			
		||||
@@ -18,10 +21,16 @@ public class TenantSpringCacheManager extends PlusSpringCacheManager {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Cache getCache(String name) {
 | 
			
		||||
        if (InterceptorIgnoreHelper.willIgnoreTenantLine("")) {
 | 
			
		||||
            return super.getCache(name);
 | 
			
		||||
        }
 | 
			
		||||
        if (StringUtils.contains(name, GlobalConstants.GLOBAL_REDIS_KEY)) {
 | 
			
		||||
            return super.getCache(name);
 | 
			
		||||
        }
 | 
			
		||||
        String tenantId = TenantHelper.getTenantId();
 | 
			
		||||
        if (StringUtils.isBlank(tenantId)) {
 | 
			
		||||
            log.error("无法获取有效的租户id -> Null");
 | 
			
		||||
        }
 | 
			
		||||
        if (StringUtils.startsWith(name, tenantId)) {
 | 
			
		||||
            // 如果存在则直接返回
 | 
			
		||||
            return super.getCache(name);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user