Commit 6b429584bfb384211bfb573a6d5303993551236d

Authored by airhead
1 parent 0e1babd7

fix(tenant): 租户缓存增加注释

yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
@@ -118,11 +118,18 @@ public class YudaoTenantAutoConfiguration { @@ -118,11 +118,18 @@ public class YudaoTenantAutoConfiguration {
118 }; 118 };
119 } 119 }
120 120
121 - @Bean  
122 - @Primary  
123 - public RedisCacheManager tenantRedisCacheManager(  
124 - RedisTemplate<String, Object> redisTemplate,  
125 - RedisCacheConfiguration redisCacheConfiguration) { 121 + /**
  122 + * 引入租户时,tenantRedisCacheManager为主Bean
  123 + *
  124 + * @param redisTemplate
  125 + * @param redisCacheConfiguration
  126 + * @return
  127 + */
  128 + @Bean
  129 + @Primary
  130 + public RedisCacheManager tenantRedisCacheManager(
  131 + RedisTemplate<String, Object> redisTemplate,
  132 + RedisCacheConfiguration redisCacheConfiguration) {
126 RedisCacheWriter cacheWriter = 133 RedisCacheWriter cacheWriter =
127 RedisCacheWriter.nonLockingRedisCacheWriter( 134 RedisCacheWriter.nonLockingRedisCacheWriter(
128 Objects.requireNonNull(redisTemplate.getConnectionFactory())); 135 Objects.requireNonNull(redisTemplate.getConnectionFactory()));
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/redis/TenantRedisCacheManager.java
@@ -8,10 +8,15 @@ import org.springframework.data.redis.cache.RedisCacheManager; @@ -8,10 +8,15 @@ import org.springframework.data.redis.cache.RedisCacheManager;
8 import org.springframework.data.redis.cache.RedisCacheWriter; 8 import org.springframework.data.redis.cache.RedisCacheWriter;
9 9
10 /** 10 /**
  11 + * 租户缓存管理
  12 + *
  13 + * 为cacheName增加自动增加租户表示,格式:name+":"+tenantId
  14 + *
11 * @author airhead 15 * @author airhead
12 */ 16 */
13 @Slf4j 17 @Slf4j
14 public class TenantRedisCacheManager extends RedisCacheManager { 18 public class TenantRedisCacheManager extends RedisCacheManager {
  19 +
15 public TenantRedisCacheManager( 20 public TenantRedisCacheManager(
16 RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration) { 21 RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration) {
17 super(cacheWriter, defaultCacheConfiguration); 22 super(cacheWriter, defaultCacheConfiguration);
@@ -19,6 +24,7 @@ public class TenantRedisCacheManager extends RedisCacheManager { @@ -19,6 +24,7 @@ public class TenantRedisCacheManager extends RedisCacheManager {
19 24
20 @Override 25 @Override
21 public Cache getCache(String name) { 26 public Cache getCache(String name) {
  27 + //租户未设置时,返回原始name
22 if (TenantContextHolder.getTenantId() == null) { 28 if (TenantContextHolder.getTenantId() == null) {
23 return super.getCache(name); 29 return super.getCache(name);
24 } 30 }