Skip to content

Commit

Permalink
1. 增加 Redis Starter
Browse files Browse the repository at this point in the history
2. 在 system-service-app 引入 Redis Starter
  • Loading branch information
YunaiV committed Dec 5, 2020
1 parent 49250eb commit 03fde36
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 2 deletions.
21 changes: 21 additions & 0 deletions common/mall-spring-boot-starter-redis/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>common</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>mall-spring-boot-starter-redis</artifactId>

<dependencies>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package cn.iocoder.mall.redis.core;

import java.time.Duration;

/**
* Redis Key 定义类
*/
public class RedisKeyDefine {

public enum KeyTypeEnum {

STRING,
LIST,
HASH,
SET,
ZSET,
STREAM,
PUBSUB;

}

/**
* 过期时间 - 永不过期
*/
public static final Duration TIMEOUT_FOREVER = null;

/**
* Key 模板
*/
private final String keyTemplate;
/**
* Key 类型的枚举
*/
private final KeyTypeEnum keyType;
/**
* Value 类型
*
* 如果是使用分布式锁,设置为 {@link java.util.concurrent.locks.Lock} 类型
*/
private final Class valueType;
/**
* 过期时间
*
* 为空时,表示永不过期 {@link #TIMEOUT_FOREVER}
*/
private final Duration timeout;

public RedisKeyDefine(String keyTemplate, KeyTypeEnum keyType, Class valueType, Duration timeout) {
this.keyTemplate = keyTemplate;
this.keyType = keyType;
this.valueType = valueType;
this.timeout = timeout;
}

public String getKeyTemplate() {
return keyTemplate;
}

public KeyTypeEnum getKeyType() {
return keyType;
}

public Class getValueType() {
return valueType;
}

public Duration getTimeout() {
return timeout;
}

}
1 change: 1 addition & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<module>mall-spring-boot-starter-system-error-code</module>
<module>mall-spring-boot-starter-rocketmq</module>
<module>mall-spring-boot-starter-xxl-job</module>
<module>mall-spring-boot-starter-redis</module>
</modules>

<dependencyManagement>
Expand Down
12 changes: 12 additions & 0 deletions mall-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<mybatis.version>3.5.4</mybatis.version>
<mybatis-plus.version>3.3.2</mybatis-plus.version>
<spring-boot-starter-data-jest.version>3.2.5.RELEASE</spring-boot-starter-data-jest.version>
<redisson.version>3.13.6</redisson.version>
<!-- RPC 相关 -->
<dubbo.version>2.7.7</dubbo.version>
<!-- MQ 相关 -->
Expand Down Expand Up @@ -145,11 +146,22 @@
<version>${spring-boot-starter-data-jest.version}</version>
</dependency>

<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>${redisson.version}</version>
</dependency>

<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-redis</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

<!-- Web 相关 -->
<dependency>
Expand Down
5 changes: 5 additions & 0 deletions system-service-project/system-service-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
</dependency>

<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-redis</artifactId>
</dependency>

<!-- 监控相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
spring:
# 数据源配置项
# MySQL 配置项
datasource:
url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 3WLiVUBEwTbvAfsh

# Spring Cloud 配置项
cloud:
nacos:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
spring:
# 数据源配置项
# MySQL 配置项
datasource:
url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 3WLiVUBEwTbvAfsh

# Redis 配置
redis:
host: 127.0.0.1
port: 6379
database: 0

# Spring Cloud 配置项
cloud:
nacos:
Expand Down

0 comments on commit 03fde36

Please sign in to comment.