-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. 在 system-service-app 引入 Redis Starter
- Loading branch information
YunaiV
committed
Dec 5, 2020
1 parent
49250eb
commit 03fde36
Showing
7 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
71 changes: 71 additions & 0 deletions
71
...ll-spring-boot-starter-redis/src/main/java/cn/iocoder/mall/redis/core/RedisKeyDefine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
system-service-project/system-service-app/src/main/resources/application-dev.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
system-service-project/system-service-app/src/main/resources/application-local.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters