补习系列(14)-springboot redis 整合-数据读写
一、简介 在 [补习系列(A3)-springboot redis 与发布订阅]() 一文中,我们介绍了使用 Redis 实现消息订阅发布的机制,并且给出了一个真实用例。然而,绝大多数场景下 Redis 是作为缓存被使用的(这是其主要优势)。除此之外,由于Redis 提供了 AOF以及RDB两种持久化机制,某些情况下也可以作为临时数据库使用。本次将介绍 SpringBoot 中如何使用 Redis 进行缓存读写。 Redis 的基本命令在学习之前,需要先了解一些Redis 的基本命令,可以参考这里 http://www.redis.cn/ 二、SpringBoot Redis 读写 A. 引入 spring-data-redis 添加依赖 <!-- redis --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <version&...
