diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml
index d7912ba69..d918cb654 100644
--- a/yudao-dependencies/pom.xml
+++ b/yudao-dependencies/pom.xml
@@ -58,6 +58,7 @@
0.1.55
2.4.1
1.3.0
+ 4.1.75.Final
8.2.2
4.6.0
@@ -131,11 +132,6 @@
yudao-spring-boot-starter-biz-error-code
${revision}
-
- cn.iocoder.boot
- yudao-spring-boot-starter-captcha
- ${revision}
-
@@ -458,12 +454,6 @@
${tika-core.version}
-
- com.anji-plus
- spring-boot-starter-captcha
- ${aj-captcha.version}
-
-
org.apache.velocity
velocity-engine-core
@@ -521,6 +511,12 @@
${jsch.version}
+
+ io.netty
+ netty-all
+ ${netty-all.version}
+
+
cn.iocoder.boot
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
index c1c969439..7896a3ad1 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.tenant.core.db.TenantDatabaseInterceptor;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJobHandlerDecorator;
import cn.iocoder.yudao.framework.tenant.core.mq.TenantRedisMessageInterceptor;
+import cn.iocoder.yudao.framework.tenant.core.redis.TenantRedisCacheManager;
import cn.iocoder.yudao.framework.tenant.core.security.TenantSecurityWebFilter;
import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService;
import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkServiceImpl;
@@ -25,6 +26,13 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.cache.RedisCacheWriter;
+import org.springframework.data.redis.core.RedisTemplate;
+
+import java.util.Objects;
@Configuration
@ConditionalOnProperty(prefix = "yudao.tenant", value = "enable", matchIfMissing = true) // 允许使用 yudao.tenant.enable=false 禁用多租户
@@ -110,4 +118,15 @@ public class YudaoTenantAutoConfiguration {
};
}
+ @Bean
+ @Primary
+ public RedisCacheManager tenantRedisCacheManager(
+ RedisTemplate redisTemplate,
+ RedisCacheConfiguration redisCacheConfiguration) {
+ RedisCacheWriter cacheWriter =
+ RedisCacheWriter.nonLockingRedisCacheWriter(
+ Objects.requireNonNull(redisTemplate.getConnectionFactory()));
+ return new TenantRedisCacheManager(cacheWriter, redisCacheConfiguration);
+ }
+
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/redis/TenantRedisCacheManager.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/redis/TenantRedisCacheManager.java
new file mode 100644
index 000000000..ab191f0d4
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/redis/TenantRedisCacheManager.java
@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.framework.tenant.core.redis;
+
+import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cache.Cache;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.cache.RedisCacheWriter;
+
+/**
+ * @author airhead
+ */
+@Slf4j
+public class TenantRedisCacheManager extends RedisCacheManager {
+ public TenantRedisCacheManager(
+ RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration) {
+ super(cacheWriter, defaultCacheConfiguration);
+ }
+
+ @Override
+ public Cache getCache(String name) {
+ if (TenantContextHolder.getTenantId() == null) {
+ return super.getCache(name);
+ }
+
+ name = name + ":" + TenantContextHolder.getTenantId();
+ return super.getCache(name);
+ }
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-redis/pom.xml b/yudao-framework/yudao-spring-boot-starter-redis/pom.xml
index 750cd4881..5c14c02fd 100644
--- a/yudao-framework/yudao-spring-boot-starter-redis/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-redis/pom.xml
@@ -32,6 +32,12 @@
spring-boot-starter-cache
+
+ io.netty
+ netty-all
+ 4.1.75.Final
+
+
diff --git a/yudao-framework/yudao-spring-boot-starter-redis/src/main/java/cn/iocoder/yudao/framework/redis/config/YudaoCacheAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-redis/src/main/java/cn/iocoder/yudao/framework/redis/config/YudaoCacheAutoConfiguration.java
index e8c716203..6a8f92efc 100644
--- a/yudao-framework/yudao-spring-boot-starter-redis/src/main/java/cn/iocoder/yudao/framework/redis/config/YudaoCacheAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-redis/src/main/java/cn/iocoder/yudao/framework/redis/config/YudaoCacheAutoConfiguration.java
@@ -1,6 +1,7 @@
package cn.iocoder.yudao.framework.redis.config;
import org.springframework.boot.autoconfigure.cache.CacheProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -13,6 +14,7 @@ import org.springframework.data.redis.serializer.RedisSerializer;
* Cache 配置类,基于 Redis 实现
*/
@Configuration
+@EnableConfigurationProperties({CacheProperties.class})
@EnableCaching
public class YudaoCacheAutoConfiguration {