1.在springboot1.x中redis客户端为jedis,但是在2.x中已经变换为lettuce.后者性能、安全方面优于前者。以下是springbootRedis中整合的新redis java客户端。

2.jedis与lettuce的区别,可在下面官网查看,这里只介绍部分内容,如下所示:

上图中有详细介绍,更具体内容请查看redis中文官网:http://www.redis.cn/clients.html#java
3.整合redis
3.1在pom添加pom依赖:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
这里使用的是2.0.1的版本
3.2编写配置

本文介绍了SpringBoot 2.x中如何整合并使用新的Redis客户端lettuce,对比了它与jedis的区别,并提供了配置文件及测试类的示例。
最低0.47元/天 解锁文章





