重redis中获取缓存参数。reids没有查询数据库。查到在放入redis中,当修改参数时,以及删除redis中缓存
来源:互联网 发布:中国核心期刊数据库 编辑:程序博客网 时间:2024/06/05 11:11
@Overridepublic String queryParamValueByKey(String paramKey) {String paramValue = null; // 系统参数配置值WithdrawParamConf config = null;/* * 先从redis缓存中获取提现开/关标志 */Object redisValue = redisTemplate.opsForValue().get(paramKey);if (redisValue != null) {paramValue = String.valueOf(redisValue);return paramValue; // 返回缓存中的结果}/* * 若缓存中不存在,则从数据库中获取 */config = withdrawParamConfDao.selectByParamName(paramKey);if (config != null) {// 将结果放入缓存中redisTemplate.opsForValue().set(paramKey, config.getParamValue(), 1, TimeUnit.DAYS);}return config.getParamValue();}
当修改系统参数时,要删除redis缓存。
修改业务参数配置(清空redis缓存)
@Overridepublic void modify(WithdrawParamConfDto systemParamConfDto) throws PaycoreException {// 1、系统参数配置必输项校验paramCheck(systemParamConfDto);//参数名称唯一性校验WithdrawParamConf confDto=withdrawParamConfDao.selectByParamName(systemParamConfDto.getParamKey());if(confDto != null){if(confDto.getId() !=systemParamConfDto.getId() ){throw new PaycoreException("参数名称不能重复");}}/* * 3、转换对象:DTO转Entity,修改系统参数配置信息 */WithdrawParamConf entity = getModifyEntity(systemParamConfDto);int result=withdrawParamConfDao.updateByPrimaryKeySelective(entity);if(result==1){WithdrawParamConf ConfDto=withdrawParamConfDao.selectByPrimaryKey(systemParamConfDto.getId());//清除redis缓存redisTemplate.delete(ConfDto.getParamKey());}}
阅读全文
0 0
- 重redis中获取缓存参数。reids没有查询数据库。查到在放入redis中,当修改参数时,以及删除redis中缓存
- tomcat启动时将缓存放入Redis中
- 在 Django 中使用 Redis 做缓存
- 在java中使用redis缓存
- 【Redis】redis实战:在业务中添加缓存机制
- CI中添加redis缓存
- Spring中集成Redis缓存
- 1 Springboot中使用redis,自动缓存、更新、删除
- 将查询的数据写到redis缓存中
- redis中缓存的数据与数据库数据一致性的方案
- JAVA中使用redis+protoStuff实现数据库缓存机制
- redis缓存中写入数据与数据库数据同步
- PHP应用中利用NoSQL数据库缓存之Redis
- 使用Spring Cache + Redis + Jackson Serializer缓存数据库查询结果中序列化问题的解决
- 逐步解说:在JavaScript中订阅Redis缓存的消息
- 如何在web项目中添加redis缓存
- 在项目中redis做缓存的一些思路
- 在Java中对Redis的缓存操作
- 动态修改App显示图标
- jquery实现html页面的导航的标签内容切换
- [Phoenix--基本配置]--链接配置选项
- linux 使用笔记
- jquery笔记(随笔)
- 重redis中获取缓存参数。reids没有查询数据库。查到在放入redis中,当修改参数时,以及删除redis中缓存
- http协议接口调用之WebClient
- 小型Basic编译器问题
- 惊了
- Spring Mybatis 返回List<Map<String,Object>>
- xml常用转义
- Spring Boot中使用Swagger2构建RESTful APIS(含源码)
- 分布式系统的Quorum策略
- 【分布式】分布式事务的一种实现方式--状态流转