mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	fix 修复 一级缓存key未区分租户问题
This commit is contained in:
		@@ -15,15 +15,17 @@ public class CaffeineCacheDecorator implements Cache {
 | 
				
			|||||||
    private static final com.github.benmanes.caffeine.cache.Cache<Object, Object>
 | 
					    private static final com.github.benmanes.caffeine.cache.Cache<Object, Object>
 | 
				
			||||||
        CAFFEINE = SpringUtils.getBean("caffeine");
 | 
					        CAFFEINE = SpringUtils.getBean("caffeine");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final String name;
 | 
				
			||||||
    private final Cache cache;
 | 
					    private final Cache cache;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public CaffeineCacheDecorator(Cache cache) {
 | 
					    public CaffeineCacheDecorator(String name, Cache cache) {
 | 
				
			||||||
 | 
					        this.name = name;
 | 
				
			||||||
        this.cache = cache;
 | 
					        this.cache = cache;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getName() {
 | 
					    public String getName() {
 | 
				
			||||||
        return cache.getName();
 | 
					        return name;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -32,7 +34,7 @@ public class CaffeineCacheDecorator implements Cache {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getUniqueKey(Object key) {
 | 
					    public String getUniqueKey(Object key) {
 | 
				
			||||||
        return cache.getName() + ":" + key;
 | 
					        return name + ":" + key;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -156,7 +156,7 @@ public class PlusSpringCacheManager implements CacheManager {
 | 
				
			|||||||
    private Cache createMap(String name, CacheConfig config) {
 | 
					    private Cache createMap(String name, CacheConfig config) {
 | 
				
			||||||
        RMap<Object, Object> map = RedisUtils.getClient().getMap(name);
 | 
					        RMap<Object, Object> map = RedisUtils.getClient().getMap(name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Cache cache = new CaffeineCacheDecorator(new RedissonCache(map, allowNullValues));
 | 
					        Cache cache = new CaffeineCacheDecorator(name, new RedissonCache(map, allowNullValues));
 | 
				
			||||||
        if (transactionAware) {
 | 
					        if (transactionAware) {
 | 
				
			||||||
            cache = new TransactionAwareCacheDecorator(cache);
 | 
					            cache = new TransactionAwareCacheDecorator(cache);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -170,7 +170,7 @@ public class PlusSpringCacheManager implements CacheManager {
 | 
				
			|||||||
    private Cache createMapCache(String name, CacheConfig config) {
 | 
					    private Cache createMapCache(String name, CacheConfig config) {
 | 
				
			||||||
        RMapCache<Object, Object> map = RedisUtils.getClient().getMapCache(name);
 | 
					        RMapCache<Object, Object> map = RedisUtils.getClient().getMapCache(name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Cache cache = new CaffeineCacheDecorator(new RedissonCache(map, config, allowNullValues));
 | 
					        Cache cache = new CaffeineCacheDecorator(name, new RedissonCache(map, config, allowNullValues));
 | 
				
			||||||
        if (transactionAware) {
 | 
					        if (transactionAware) {
 | 
				
			||||||
            cache = new TransactionAwareCacheDecorator(cache);
 | 
					            cache = new TransactionAwareCacheDecorator(cache);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user