Commit 8527bd3c77eed465304fd19238cb662e44dccefa

Authored by airhead
1 parent 310b5b00

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 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 133 RedisCacheWriter cacheWriter =
127 134 RedisCacheWriter.nonLockingRedisCacheWriter(
128 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 8 import org.springframework.data.redis.cache.RedisCacheWriter;
9 9  
10 10 /**
  11 + * 租户缓存管理
  12 + *
  13 + * 为cacheName增加自动增加租户表示,格式:name+":"+tenantId
  14 + *
11 15 * @author airhead
12 16 */
13 17 @Slf4j
14 18 public class TenantRedisCacheManager extends RedisCacheManager {
  19 +
15 20 public TenantRedisCacheManager(
16 21 RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration) {
17 22 super(cacheWriter, defaultCacheConfiguration);
... ... @@ -19,6 +24,7 @@ public class TenantRedisCacheManager extends RedisCacheManager {
19 24  
20 25 @Override
21 26 public Cache getCache(String name) {
  27 + //租户未设置时,返回原始name
22 28 if (TenantContextHolder.getTenantId() == null) {
23 29 return super.getCache(name);
24 30 }
... ...