zoukankan      html  css  js  c++  java
  • redis20

    需知  

      目前 java 操作 redis 的客户端有jedis Lettuce

      在 springboot1.x 系列中,使用的是 jedis

      到了 springboot2.x 系列使用的是 Lettuce

      目前我们线上开发基本上都使用的版本是 springboot2.x 系列,所以我们需要会使用 Lettuce

      关于 jedis lettuce 的区别在 redis19 章节已经聊过了,这里就不做冗余阐述了。

    实现步骤

     1、添加 pom 依赖

    <!--springboot中的redis依赖-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
    <!-- lettuce pool 缓存连接池-->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-pool2</artifactId>
    </dependency>

      注意点:使用pool,那么必须在 pom.xml 添加上 commons-pool2 的依赖。没配置 pool 的话,可以不引用。

     2、配置 redis.properties,其中如下:

    spring.redis.host=127.0.0.1
    spring.redis.port=6379
    #连接池最大链接数默认值为8
    spring.redis.lettuce.pool.max-active=8
    #连接池最大阻塞时间(使用负值表示没有限制)默认为-1
    spring.redis.lettuce.pool.max-wait=-1
    #连接池中的最大空闲连接数 默认为8
    spring.redis.lettuce.pool.max-idle=8
    #连接池中的最小空闲连接数 默认为8
    spring.redis.lettuce.pool.min-idle=0
  • 相关阅读:
    iptables操作指令
    最怕问初衷,大梦成空
    kettle官网wiki
    Pentaho Spoon (Kettle) 出现 Timestamp :Unable to get timestamp from resultset at index 30 错误的解决
    win10安装vs2013失败解决方法
    2020 最新 kail 安装教程
    01_docker学习笔记(一)
    数据结构的基础概念
    BOS3
    配置文件添加druid控制台
  • 原文地址:https://www.cnblogs.com/liang1101/p/13507156.html
Copyright © 2011-2022 走看看