Merge branch 'master' into fix-663

This commit is contained in:
chenjun committed 2019-10-31 23:32:29 +08:00
commit 503dd2ad72
2 files changed
+12

No files matched your search

@@ -8,6 +8,13 @@ package com.pig4cloud.pigx.common.core.constant;
*/
public interface CacheConstants {
/**
* 全局缓存,在缓存名称上加上该前缀表示该缓存不区分租户,比如:
* <P/>
* {@code @Cacheable(value = CacheConstants.GLOBALLY+CacheConstants.MENU_DETAILS, key = "#roleId + '_menu'", unless = "#result == null")}
*/
String GLOBALLY = "gl@";
/**
* 菜单信息缓存
*/
@@ -18,6 +18,7 @@
package com.pig4cloud.pigx.common.data.cache;
import cn.hutool.core.util.StrUtil;
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.Cache;
@@ -73,6 +74,10 @@ public class RedisAutoCacheManager extends RedisCacheManager {
*/
@Override
public Cache getCache(String name) {
// see https://gitee.wang/pig/pigx/issues/613
if(name.startsWith(CacheConstants.GLOBALLY)){
return super.getCache(name);
}
return super.getCache(TenantContextHolder.getTenantId() + StrUtil.COLON + name);
}
}