mirror of
https://gitee.com/zhijiantianya/ruoyi-vue-pro.git
synced 2026-03-22 05:07:17 +08:00
!1474 fix:支持自定义过期时间的缓存key,不能忽略租户问题
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
yudao-ui-admin CI / build (14.x) (push) Has been cancelled
yudao-ui-admin CI / build (16.x) (push) Has been cancelled
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
yudao-ui-admin CI / build (14.x) (push) Has been cancelled
yudao-ui-admin CI / build (16.x) (push) Has been cancelled
Merge pull request !1474 from Joyen/fix-cacheable
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.framework.tenant.core.redis;
|
package cn.iocoder.yudao.framework.tenant.core.redis;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.redis.core.TimeoutRedisCacheManager;
|
import cn.iocoder.yudao.framework.redis.core.TimeoutRedisCacheManager;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -21,6 +22,8 @@ import java.util.Set;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class TenantRedisCacheManager extends TimeoutRedisCacheManager {
|
public class TenantRedisCacheManager extends TimeoutRedisCacheManager {
|
||||||
|
|
||||||
|
private static final String SPLIT = "#";
|
||||||
|
|
||||||
private final Set<String> ignoreCaches;
|
private final Set<String> ignoreCaches;
|
||||||
|
|
||||||
public TenantRedisCacheManager(RedisCacheWriter cacheWriter,
|
public TenantRedisCacheManager(RedisCacheWriter cacheWriter,
|
||||||
@@ -32,10 +35,11 @@ public class TenantRedisCacheManager extends TimeoutRedisCacheManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cache getCache(String name) {
|
public Cache getCache(String name) {
|
||||||
|
String[] names = StrUtil.splitToArray(name, SPLIT);
|
||||||
// 如果开启多租户,则 name 拼接租户后缀
|
// 如果开启多租户,则 name 拼接租户后缀
|
||||||
if (!TenantContextHolder.isIgnore()
|
if (!TenantContextHolder.isIgnore()
|
||||||
&& TenantContextHolder.getTenantId() != null
|
&& TenantContextHolder.getTenantId() != null
|
||||||
&& !CollUtil.contains(ignoreCaches, name)) {
|
&& !CollUtil.contains(ignoreCaches, names[0])) {
|
||||||
name = name + ":" + TenantContextHolder.getTenantId();
|
name = name + ":" + TenantContextHolder.getTenantId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user