需求描述:Springboot cache框架+Caffeine/redis(可切换或共用)
配置文件:
pom依赖:
CacheConfig:所有的装配动作都在此,各类型缓存装配,keygenerator,超时,等。
@Autowired private RedisConnectionFactory factory; @Autowired private CaffeineSpec spec; @Autowired private CacheResolves cacheresolves; @Bean public CacheResolver setResolver(){ cacheresolves.setType("redis"); cacheresolves.setCaffeineMan(caffeineManager()); cacheresolves.setRedisMan(redisManager()); return cacheresolves; } @Bean public CacheManager caffeineManager(){ CaffeineCacheManager manager=new CaffeineCacheManager(); manager.setCaffeineSpec(spec); manage