@Cacheable缓存解决双冒号::问题
使用spring-data-redis2.x版本时,@Cacheable缓存key值时默认会给vlue或cacheNames后加上双引号
通过配置进行修改即可满足项目需求
@Configuration
public class SpringCacheConfig{
@Bean
public CacheManager cacheManager(LettuceConnectionFactory lettuceConnectionFactory){
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
.entryTtl(Duration.ofHour(1)
//变双冒号为单冒号
.computePrefixWith(name - >":")
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer()))
.disableCachingNullValues();
RedisCacheManager cacheManager = RedisCacheManager.RedisCacheManagerBuilder
.fromConnectionFactory(lettuceConnectionFactory)
.cacheDefaults(config)
.transactionAware()
.build();
return cacheManager;
}
...其他配置
}
本文地址:https://blog.csdn.net/u012725623/article/details/107671343
上一篇: 爱奇艺手机客户端怎么订阅电视剧以便及时收到更新提醒
下一篇: 【算法】解压字符串(猿辅导笔试题)