# Redis 客户端

# 描述

框架中实现了Redis连接,让您不需要在对连接Redis进行关注,配置完连接地址,导入框架提供的配置就可以直接进行使用。

# 开始使用

# 添加Maven依赖

Spring boot 的 Redis 依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
1
2
3
4

# @Import导入

在标注了@SpringBootApplication中,使用@Import导入QmRedisConfig

注意:

注意:1.0.1版本以下,需要额外导入QmSpringManager

@SpringBootApplication
@Import({
        QmFrameworkApplication.class,
        QmRedisConfig.class
})
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}
1
2
3
4
5
6
7
8
9
10
11
12

# YML配置连接

spring:
  redis:
    database: 0 # Redis数据库索引(默认为0)
    host: 'localhost' # Redis服务器地址
    port: 6379 # Redis服务器连接端口
    password: '' # Redis服务器连接密码(默认为空)
    pool:
      max-active: 200 # 连接池最大连接数(使用负值表示没有限制)
      max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
      max-idle: 10 # 连接池中的最大空闲连接
      min-idle: 0 # 连接池中的最小空闲连接
    timeout: 1000 # 连接超时时间(毫秒)
1
2
3
4
5
6
7
8
9
10
11
12

# 调用QmRedisClient

上述配置成功后,直接调用QmRedisClient即可。

最近更新: 2020/5/29 上午2:22:19