当前位置:网站首页>Remember to configure the expiration time of @Cacheable (Redis specifies the expiration time of certain Cache Keys)
Remember to configure the expiration time of @Cacheable (Redis specifies the expiration time of certain Cache Keys)
2022-08-06 17:28:00 【OK_boom】
All configurations are being generatedRedisCacheManagershould have been specified before(在Builder里面),The following code is specifiedBuilderThe default configuration and specify certainkey的配置的 代码:
// 配置序列化(解决乱码的问题),And configure the cache default validity period 6小时
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(6));
RedisCacheConfiguration redisCacheConfiguration = config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer));
...
RedisCacheManager.RedisCacheManagerBuilder builder=RedisCacheManager.builder(writer).cacheDefaults(redisCacheConfiguration)
.withInitialCacheConfigurations(singletonMap(CacheConstant.SYS_DICT_TABLE_CACHE,
RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(10)).disableCachingNullValues()
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRe
disSerializer))));
...
//Access custom configuration
for (String v:keyExpire){
String[] items=v.split(",");
if (items.length!=2){
throw new IllegalArgumentException("Invalid configuration parameter:jeecg.redis.key-expire:"+v);
}
builder.withInitialCacheConfigurations(singletonMap(items[0],
RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(Long.valueOf(items[1]))).disableCachingNullValues()
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer))));
}
RedisCacheManager cacheManager=builder.transactionAware().build();
return cacheManager;
在applicationdefine somecache keyThe expiration time is the same as in the code abovekeyExpire对接
redis:
#Custom cache key validity period,秒
key-expire:
- smp:order:status:list,300
@Cacheable调用:
@Override
@Cacheable(value = CACHE_STATUS_LIST,key="#tenantId+'-'+T(com.freestyle.common.CacheIdUtil).toId(#queryWrapper,#queryWrapper)")
public IPage<SmpOrderStatus> page(String tenantId, Page<SmpOrderStatus> page, QueryWrapper<SmpOrderStatus> queryWrapper) {
return super.page(page,queryWrapper);
}
边栏推荐
- win7和win10哪个占用资源少 win7和win10占用资源详解
- how to unblock google browser firewall how to disable firewall blocking chrome browser
- win7台式机如何调整屏幕亮度 win7设置屏幕亮度
- CMake教程Step7(安装打包)
- Computational Protein Design with Deep Learning Neural Networks
- 为什么要ROS2而不是对ROS1修修补补?
- 快捷方式指向的驱动器或网络连接不可用怎么解决
- `QT` exe打包发布
- win7旗舰版64位万能激活码 windows7旗舰版激活产品密钥
- SourceTree使用技巧
猜你喜欢
随机推荐
win7旗舰版64位万能激活码 windows7旗舰版激活产品密钥
win7缺失dll文件一键修复 msvcr120.dll丢失怎样修复win7
【TOML配置文件】配置文件我用TOML!人性化,少出错!
赞!图像几何三维重建代码实战教程来啦!深度计算+点云处理+网格重建优化+纹理贴图!
02 【常用类型(上)】
`Mathematics` Fundamental Theorem of Calculus
为什么要ROS2而不是对ROS1修修补补?
how to unblock google browser firewall how to disable firewall blocking chrome browser
开机f1修复电脑步骤 开机需要按F1才能进入系统
ip地址配置错误网络无法连接怎么解决win7
【kali-漏洞利用】(3.3)后渗透之Meterpreter(上):命令大全
win7开机0x0000007b修复不了 win7开机蓝屏0x0000007b
为什么欧美地区,都认为百度SEO就是首页排名?
2022年华数杯C题资料汇总
设备树
FR9608SP SOP-8 28V、3A、340 KHz同步降压DC/DC转换器
IPv6 理论教程
软件测试周刊(第83期):当你感觉忙得没时间休息,就是你最需要找时间休息的时候。
国内首个聚焦制造行业的BI白皮书来了!
面试20场,我总结了面试问题及解答!激光+IMU融合定位方向









