mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
fix(tenant): 租户缓存增加注释
This commit is contained in:
parent
0e1babd7f4
commit
6b429584bf
@ -118,11 +118,18 @@ public class YudaoTenantAutoConfiguration {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
/**
|
||||||
@Primary
|
* 引入租户时,tenantRedisCacheManager为主Bean
|
||||||
public RedisCacheManager tenantRedisCacheManager(
|
*
|
||||||
RedisTemplate<String, Object> redisTemplate,
|
* @param redisTemplate
|
||||||
RedisCacheConfiguration redisCacheConfiguration) {
|
* @param redisCacheConfiguration
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public RedisCacheManager tenantRedisCacheManager(
|
||||||
|
RedisTemplate<String, Object> redisTemplate,
|
||||||
|
RedisCacheConfiguration redisCacheConfiguration) {
|
||||||
RedisCacheWriter cacheWriter =
|
RedisCacheWriter cacheWriter =
|
||||||
RedisCacheWriter.nonLockingRedisCacheWriter(
|
RedisCacheWriter.nonLockingRedisCacheWriter(
|
||||||
Objects.requireNonNull(redisTemplate.getConnectionFactory()));
|
Objects.requireNonNull(redisTemplate.getConnectionFactory()));
|
||||||
|
@ -8,10 +8,15 @@ import org.springframework.data.redis.cache.RedisCacheManager;
|
|||||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 租户缓存管理
|
||||||
|
*
|
||||||
|
* 为cacheName增加自动增加租户表示,格式:name+":"+tenantId
|
||||||
|
*
|
||||||
* @author airhead
|
* @author airhead
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class TenantRedisCacheManager extends RedisCacheManager {
|
public class TenantRedisCacheManager extends RedisCacheManager {
|
||||||
|
|
||||||
public TenantRedisCacheManager(
|
public TenantRedisCacheManager(
|
||||||
RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration) {
|
RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration) {
|
||||||
super(cacheWriter, defaultCacheConfiguration);
|
super(cacheWriter, defaultCacheConfiguration);
|
||||||
@ -19,6 +24,7 @@ public class TenantRedisCacheManager extends RedisCacheManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cache getCache(String name) {
|
public Cache getCache(String name) {
|
||||||
|
//租户未设置时,返回原始name
|
||||||
if (TenantContextHolder.getTenantId() == null) {
|
if (TenantContextHolder.getTenantId() == null) {
|
||||||
return super.getCache(name);
|
return super.getCache(name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user