spring-boot集成6:集成redis实现字典缓存功能
Why redis?
redis是基于内存的key-value系统,可以用作缓存中间件或者消息中间件,spring-boot提供了方便的方式和redis集成。
1.maven依赖
<!--redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
2.配置
spring:
application:
name: monocase-framework # 应用名称
jackson:
date-format: yyyy-MM-dd HH:mm:ss # 日期格式
datasource:
druid: # 连接池别名
url: jdbc:mysql://${MYSQL_HOST:192.168.1.200}:${MYSQL_PORT:3306}/zhya-monocase-framework?useUnicode=true&characterEncoding=utf8
username: root
password: root@123
type: com.alibaba.druid.pool.DruidDataSource # 连接池类型
driver-class-name: com.mysql.jdbc.Driver
poolPreparedStatements: true
maxOpenPreparedStatements: 100
maxActive: 100
maxWaitMillis: 5000
redis:
database: 1
host: ${REDIS_HOST:192.168.1.200}
port: ${REDIS_PORT:6379}
jedis:
pool:
max-active: 100
max-wait: 2000ms
3.实例

4.测试
第一次会进行数据库查询

第二次则不会,因为redis中已经缓存了

spring-boot集成6:集成redis实现字典缓存功能的更多相关文章
- 7、Spring Boot 2.x 集成 Redis
1.7 Spring Boot 2.x 集成 Redis 简介 继续上篇的MyBatis操作,详细介绍在Spring Boot中使用RedisCacheManager作为缓存管理器,集成业务于一体. ...
- Spring Boot 如何快速集成 Redis 哨兵?
上一篇:Spring Boot 如何快速集成 Redis? 前面的分享栈长介绍了如何使用 Spring Boot 快速集成 Redis,上一篇是单机版,也有粉丝留言说有没有 Redis Sentine ...
- spring boot rest 接口集成 spring security(2) - JWT配置
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- spring boot rest 接口集成 spring security(1) - 最简配置
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- spring boot / cloud (三) 集成springfox-swagger2构建在线API文档
spring boot / cloud (三) 集成springfox-swagger2构建在线API文档 前言 不能同步更新API文档会有什么问题? 理想情况下,为所开发的服务编写接口文档,能提高与 ...
- Spring Boot HikariCP 一 ——集成多数据源
其实这里介绍的东西主要是参考的另外一篇文章,数据库读写分离的. 参考文章就把链接贴出来,里面有那位的代码,简单明了https://gitee.com/comven/dynamic-datasource ...
- Spring Boot系列——如何集成Log4j2
上篇<Spring Boot系列--日志配置>介绍了Spring Boot如何进行日志配置,日志系统用的是Spring Boot默认的LogBack. 事实上,除了使用默认的LogBack ...
- 【ELK】4.spring boot 2.X集成ES spring-data-ES 进行CRUD操作 完整版+kibana管理ES的index操作
spring boot 2.X集成ES 进行CRUD操作 完整版 内容包括: ============================================================ ...
- 15、Spring Boot 2.x 集成 Swagger UI
1.15.Spring Boot 2.x 集成 Swagger UI 完整源码: Spring-Boot-Demos 1.15.1 pom文件添加swagger包 <swagger2.versi ...
随机推荐
- 详解mpstat等性能监测命令的使用
mpstat是Multiprocessor Statistics的缩写,是实时监控工具,报告与cpu的一些统计信息这些信息都存在/proc/stat文件中,在多CPU系统里,其不但能查看所有的CPU的 ...
- go包中的init() 函数
https://tutorialedge.net/golang/the-go-init-function/ ---------------------------------------------- ...
- python——flask常见接口开发(简单案例)
python——flask常见接口开发(简单案例)原创 大蛇王 发布于2019-01-24 11:34:06 阅读数 5208 收藏展开 版本:python3.5+ 模块:flask 目标:开发一个只 ...
- [唐胡璐]QTP技巧 - QTP菜单项消失
有时候QTP的菜单栏的下拉菜单为空。 解决方法:在菜单栏点击右键,选择“Customize”,在Customize窗口的ToolBarTab页,点击“Restore All”后即可。
- tar命令--数据解档(三)解压.tar.gz文件报错 gzip:stdin:not in gzip format
毕竟是生产..... 提示以下信息: gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not ...
- python常用函数拾零
Python常用内置函数总结: 整理过程中参考了runoob网站中python内置函数的相关知识点,特此鸣谢!! 原文地址:http://www.runoob.com/python/python-bu ...
- [ERROR ] The Salt Master has cached the public key for this node, this salt minion will wait for 10 seconds before attempting to re-authenticate
2.salt master已缓存此节点的公钥,此salt minion将等待10秒,然后再尝试重新验证. [ERROR ] The Salt Master has cached the public ...
- [Javascript] Customize Behavior when Accessing Properties with Proxy Handlers
A Proxy allows you to trap what happens when you try to get a property value off of an object and do ...
- ACM之路(16)—— 数位DP
题目就是kuangbin的数位DP. 先讲C题,不要62,差不多就是一个模板题.要注意的是按位来的话,光一个pos是不够的,还需要一维来记录当前位置是什么数字,这样才能防止同一个pos不同数字的dp值 ...
- javascript中的BOM
浏览器对象模型BOM,提供了访问浏览器的接口.这些功能大多和网页内容无关,多年来,由于缺乏规范导致BOM中的不同方法在不同浏览器中的实现有所差异,直到html5,才将BOM的主要方面纳入规范. BOM ...