1、缓存问题修改

This commit is contained in:
zhengyf 2025-08-23 14:20:02 +08:00
parent d20d493522
commit d1954cb64b
1 changed files with 17 additions and 10 deletions

View File

@ -5,28 +5,35 @@ import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.cache.support.SimpleCacheManager; import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
@Configuration @Configuration
@EnableCaching @EnableCaching
public class CacheConfig extends CachingConfigurerSupport { public class CacheConfig extends CachingConfigurerSupport {
@Override
@Bean @Bean
public CacheManager cacheManager() { public ConcurrentMapCacheManager cacheManager() {
SimpleCacheManager cacheManager = new SimpleCacheManager(); // 整合所有需要的缓存名称原有的mdm相关缓存 + 新的业务缓存
List<String> cacheNames = Arrays.asList(
// 添加所有需要的缓存包括缺失的mdmModuleDb // 原有缓存来自SimpleCacheManager的配置
List<Cache> caches = new ArrayList<>(); "mdmModuleDb",
caches.add(new ConcurrentMapCache("mdmModuleDb")); "mdmModuleDbFileds",
caches.add(new ConcurrentMapCache("mdmModuleDbFileds")); "mdmModule",
caches.add(new ConcurrentMapCache("mdmModule")); // 新添加的业务缓存来自之前的ConcurrentMapCacheManager配置
"sysApplicationPlugin",
cacheManager.setCaches(caches); "IntegrationTask",
"IntegrationTaskLiving"
);
ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager();
cacheManager.setCacheNames(cacheNames); // 注册所有缓存名称
return cacheManager; return cacheManager;
} }
} }