👋 欢迎浏览我的技术博客,记录学习笔记 本人28届软工一枚

5.5 redis 的使用(Spring Boot 集成 Redis)

  1. 电脑上配置好 Redis
  2. 引入依赖: spring-boot-starter-data-redis
  3. 配置文件(application.yml / application.properties):
    yaml

spring:
data:
redis:
host:
port:
 
4. 使用  StringRedisTemplate.opsForValue()  获取操作集合
5. 在登录时生成 token
6. 在  Interceptor  里注入StringRedisTemplate并获取 token,如果为空则抛出异常:

new RuntimeException()
 
7. 在更新密码时,需要获取 Redis 的  StringRedisTemplate  对象,调用  opsForValue().delete(token)

posted @ 2026-05-10 12:39  气球飞起  阅读(15)  评论(0)    收藏  举报