SaToken利用Redis做持久化

官网解释

官网解释

教程

引入依赖

xml 复制代码
<!-- 提供Redis连接池 -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-pool2</artifactId>
</dependency>

<!-- Sa-Token 整合 Redis (使用 jdk 默认序列化方式) -->
<!--        <dependency>-->
<!--            <groupId>cn.dev33</groupId>-->
<!--            <artifactId>sa-token-redis</artifactId>-->
<!--            <version>1.37.0</version>-->
<!--        </dependency>-->

<!-- Sa-Token 整合 Redis (使用 jackson 序列化方式) -->
<dependency>
    <groupId>cn.dev33</groupId>
    <artifactId>sa-token-redis-jackson</artifactId>
    <version>1.37.0</version>
</dependency>
<!--核心依赖-->
<dependency>
    <groupId>cn.dev33</groupId>
    <artifactId>sa-token-spring-boot-starter</artifactId>
    <version>1.37.0</version>
</dependency>

添加配置

yml 复制代码
spring:
  # redis配置
  redis:
    # Redis数据库索引(默认为0)
    database: 0
    # Redis服务器地址
    host: 127.0.0.1
    # Redis服务器连接端口
    port: 6379
    # Redis服务器连接密码(默认为空)
    # password:
    # 连接超时时间
    timeout: 10s
    lettuce:
      pool:
        # 连接池最大连接数
        max-active: 200
        # 连接池最大阻塞等待时间(使用负值表示没有限制)
        max-wait: -1ms
        # 连接池中的最大空闲连接
        max-idle: 10
        # 连接池中的最小空闲连接
        min-idle: 0

看看你本地的SaToken就知道了

相关推荐
Seven9718 小时前
剑指offer-31、整数中1出现的次数
redis
AAA修煤气灶刘哥2 天前
别让Redis「歪脖子」!一次搞定数据倾斜与请求倾斜的捉妖记
redis·分布式·后端
christine-rr3 天前
linux常用命令(4)——压缩命令
linux·服务器·redis
凯子坚持 c3 天前
精通 Redis list:使用 redis-plus-plus 的现代 C++ 实践深度解析
c++·redis·list
weixin_456904273 天前
跨域(CORS)和缓存中间件(Redis)深度解析
redis·缓存·中间件
波波烤鸭3 天前
Redis 高可用实战源码解析(Sentinel + Cluster 整合应用)
数据库·redis·sentinel
MarkHard1233 天前
如何利用redis使用一个滑动窗口限流
数据库·redis·缓存
island13143 天前
【Redis#10】渐进式遍历 | 数据库管理 | redis_cli | RES
数据库·redis·bootstrap
心想事成的幸运大王3 天前
Redis的过期策略
数据库·redis·缓存
wuyunhang1234563 天前
Redis---集群模式
数据库·redis·缓存