Spring Boot 揭秘与实战(二) 数据缓存篇 - Redis Cache
文章目录
本文,讲解 Spring Boot 如何集成 Redis Cache,实现缓存。
在阅读「Spring Boot 揭秘与实战(二) 数据缓存篇 - 快速入门」后,对 Spring Boot 集成缓存机制有一定了解后,我们来了解下 Redis Cache 的使用。
Redis Cache 集成
Redis Cache 有非常丰富的使用场景,如果有兴趣的话,可以阅读这篇文章「Redis实战(五) 聊聊Redis使用场景」。
在 Spring Boot 中集成 Redis Cache 非常容易,只需要两个步骤。
首先,在 pom.xml 中增加Redis 依赖。
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-redis</artifactId>
- </dependency>
第二步,在 src/main/resources/application.properties 中配置数据源信息。
- spring.redis.host=localhost
- spring.redis.port=6379
- spring.redis.password=
- spring.redis.database=1
- spring.redis.pool.max-active=8
- spring.redis.pool.max-wait=-1
- spring.redis.pool.max-idle=500
- spring.redis.pool.min-idle=0
- spring.redis.timeout=0
运行起来,控制台打印的日志信息,说明已经是 Redis Cache 实例,说明 Redis Cache 开启成功了。
- Bean 'cacheManager' of type [class org.springframework.data.redis.cache.RedisCacheManager]
源代码
相关示例完整代码: springboot-action
(完)
如果觉得我的文章对你有帮助,请随意打赏。

- 版权声明:本文由 梁桂钊 发表于 梁桂钊的博客
- 转载声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证),非商业转载请注明作者及出处,商业转载请联系作者本人。
- 文章标题:Spring Boot 揭秘与实战(二) 数据缓存篇 - Redis Cache
- 文章链接:http://blog.720ui.com/2017/springboot_02_data_cache_rediscache/
Spring Boot 揭秘与实战(二) 数据缓存篇 - Redis Cache的更多相关文章
- Spring Boot 揭秘与实战(二) 数据缓存篇 - Guava Cache
文章目录 1. Guava Cache 集成 2. 个性化配置 3. 源代码 本文,讲解 Spring Boot 如何集成 Guava Cache,实现缓存. 在阅读「Spring Boot 揭秘与实 ...
- Spring Boot 揭秘与实战(二) 数据缓存篇 - EhCache
文章目录 1. EhCache 集成 2. 源代码 本文,讲解 Spring Boot 如何集成 EhCache,实现缓存. 在阅读「Spring Boot 揭秘与实战(二) 数据缓存篇 - 快速入门 ...
- Spring Boot 揭秘与实战(二) 数据缓存篇 - 快速入门
文章目录 1. 声明式缓存 2. Spring Boot默认集成CacheManager 3. 默认的 ConcurrenMapCacheManager 4. 实战演练5. 扩展阅读 4.1. Mav ...
- Spring Boot 揭秘与实战(二) 数据存储篇 - 声明式事务管理
文章目录 1. 声明式事务 2. Spring Boot默认集成事务 3. 实战演练4. 源代码 3.1. 实体对象 3.2. DAO 相关 3.3. Service 相关 3.4. 测试,测试 本文 ...
- Spring Boot 揭秘与实战(二) 数据存储篇 - ElasticSearch
文章目录 1. 版本须知 2. 环境依赖 3. 数据源 3.1. 方案一 使用 Spring Boot 默认配置 3.2. 方案二 手动创建 4. 业务操作5. 总结 4.1. 实体对象 4.2. D ...
- Spring Boot 揭秘与实战(二) 数据存储篇 - MongoDB
文章目录 1. 环境依赖 2. 数据源 2.1. 方案一 使用 Spring Boot 默认配置 2.2. 方案二 手动创建 3. 使用mongoTemplate操作4. 总结 3.1. 实体对象 3 ...
- Spring Boot 揭秘与实战(二) 数据存储篇 - Redis
文章目录 1. 环境依赖 2. 数据源 2.1. 方案一 使用 Spring Boot 默认配置 2.2. 方案二 手动创建 3. 使用 redisTemplate 操作4. 总结 3.1. 工具类 ...
- Spring Boot 揭秘与实战(二) 数据存储篇 - JPA整合
文章目录 1. 环境依赖 2. 数据源 3. 脚本初始化 4. JPA 整合方案一 通过继承 JpaRepository 接口 4.1. 实体对象 4.2. DAO相关 4.3. Service相关 ...
- Spring Boot 揭秘与实战(二) 数据存储篇 - MyBatis整合
文章目录 1. 环境依赖 2. 数据源3. 脚本初始化 2.1. 方案一 使用 Spring Boot 默认配置 2.2. 方案二 手动创建 4. MyBatis整合5. 总结 4.1. 方案一 通过 ...
随机推荐
- hdu-6437-最大费用流
Problem L.Videos Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Other ...
- 鼠标放上改变Button的大小
private void enterBtn_MouseLeave(object sender, MouseEventArgs e) { enterBtn.Wi ...
- Oracle表空间状态
1.表空间只读 查看当前表空间状态 SYS@userdata>column file_name format a60 SYS@userdata>column tablespace_name ...
- os模块,序列化模块,json模块,pickle模块
一.os模块os.system("bash command") 运行shell命令,直接显示 os.popen("bash command).read() 运行shell ...
- 十七、Spring框架(IOC/DI)
一.Spring框架 Spring是一个基于IOC和AOP的结构J2EE系统的框架. 1.IOC反转控制是Spring的基础(Inversion Of Control).也就是说创建对象由以前的程序员 ...
- noip2014生活大爆炸版石头剪刀布
题目描述 石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头.如果两个人出拳一 样,则不分胜负.在<生活大爆炸>第二季第8集中出现了一种石头剪刀布的升级版游戏. 升级版游戏在传统的 ...
- noip2016组合数问题
题目描述 组合数 Cnm 表示的是从 n 个物品中选出 m 个物品的方案数.举个例子,从 (1,2,3) 三个物品中选择两个物品可以有(1,2),(1,3),(2,3) 这三种选择方法.根据组合数的 ...
- Android AES加密报错处理:javax.crypto.IllegalBlockSizeException: error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH
一.问题说明 今天写AES加/解密功能的apk,设想是四个控件(测试用的,界面丑这种东西请忽略) 一个编缉框----用于输入要加密的字符串 一个文本框----用于输出加密后的字符串,和加密后点击解密按 ...
- Spring Boot + Spring Cloud 实现权限管理系统 后端篇(十一):集成 Shiro 框架
Apache Shiro 优势特点 它是一个功能强大.灵活的,优秀开源的安全框架. 它可以处理身份验证.授权.企业会话管理和加密. 它易于使用和理解,相比Spring Security入门门槛低. 主 ...
- chrome google mozilla firefox bookmarks import export
chrome导出导入bookmarks 1◆ google帐号 自己申请,脑补 2◆ google访问 脑补 suggestion Lantern 3◆ 步骤 4◆ 导入 sample ...