Skip to content

Commit 3774464

Browse files
committed
feat: 完善 plugin cache
1 parent 9e81670 commit 3774464

12 files changed

Lines changed: 48 additions & 32 deletions

File tree

common/core/pom.xml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,11 @@
3838
<groupId>org.springframework.boot</groupId>
3939
<artifactId>spring-boot-configuration-processor</artifactId>
4040
</dependency>
41-
<!--SpringBoot Cache-->
42-
<dependency>
43-
<groupId>org.springframework.boot</groupId>
44-
<artifactId>spring-boot-starter-cache</artifactId>
45-
</dependency>
46-
<!--RedisTemplate-->
47-
<dependency>
48-
<groupId>org.springframework.boot</groupId>
49-
<artifactId>spring-boot-starter-data-redis</artifactId>
50-
</dependency>
51-
<!--commons-pool2(RedisTemplate 依赖)-->
52-
<dependency>
53-
<groupId>org.apache.commons</groupId>
54-
<artifactId>commons-pool2</artifactId>
55-
</dependency>
5641
<!--spring retry-->
5742
<dependency>
5843
<groupId>org.springframework.retry</groupId>
5944
<artifactId>spring-retry</artifactId>
6045
</dependency>
61-
<!--caffeine-->
62-
<dependency>
63-
<groupId>com.github.ben-manes.caffeine</groupId>
64-
<artifactId>caffeine</artifactId>
65-
</dependency>
6646
<!--ttl-->
6747
<dependency>
6848
<groupId>com.alibaba</groupId>

common/plugin/cache/pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,31 @@
1111

1212
<artifactId>uni-boot-common-plugin-cache</artifactId>
1313

14+
<dependencies>
15+
<dependency>
16+
<groupId>top.cadecode</groupId>
17+
<artifactId>uni-boot-common-core</artifactId>
18+
</dependency>
19+
<!--SpringBoot Cache-->
20+
<dependency>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-starter-cache</artifactId>
23+
</dependency>
24+
<!--RedisTemplate-->
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-data-redis</artifactId>
28+
</dependency>
29+
<!--commons-pool2(RedisTemplate 依赖)-->
30+
<dependency>
31+
<groupId>org.apache.commons</groupId>
32+
<artifactId>commons-pool2</artifactId>
33+
</dependency>
34+
<!--caffeine-->
35+
<dependency>
36+
<groupId>com.github.ben-manes.caffeine</groupId>
37+
<artifactId>caffeine</artifactId>
38+
</dependency>
39+
</dependencies>
40+
1441
</project>

framework/src/main/java/top/cadecode/uniboot/framework/config/CacheConfig.java renamed to common/plugin/cache/src/main/java/top/cadecode/uniboot/common/plugin/cache/config/CacheConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package top.cadecode.uniboot.framework.config;
1+
package top.cadecode.uniboot.common.plugin.cache.config;
22

33
import com.github.benmanes.caffeine.cache.Caffeine;
44
import lombok.RequiredArgsConstructor;

framework/src/main/java/top/cadecode/uniboot/framework/config/RedisConfig.java renamed to common/plugin/cache/src/main/java/top/cadecode/uniboot/common/plugin/cache/config/RedisConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package top.cadecode.uniboot.framework.config;
1+
package top.cadecode.uniboot.common.plugin.cache.config;
22

33
import lombok.RequiredArgsConstructor;
44
import org.springframework.context.annotation.Bean;

common/core/src/main/java/top/cadecode/uniboot/common/core/datasource/CacheKeyGenerator.java renamed to common/plugin/cache/src/main/java/top/cadecode/uniboot/common/plugin/cache/util/CacheKeyGenerator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package top.cadecode.uniboot.common.core.datasource;
1+
package top.cadecode.uniboot.common.plugin.cache.util;
22

33
/**
44
* Redis key 命名生成器
@@ -23,4 +23,8 @@ public static String key(String prefix, String... extra) {
2323
return prefixBuilder.toString();
2424
}
2525

26+
public static String lockKey(String... extra) {
27+
return key("lock", extra);
28+
}
29+
2630
}

common/core/src/main/java/top/cadecode/uniboot/common/core/util/RedisLock.java renamed to common/plugin/cache/src/main/java/top/cadecode/uniboot/common/plugin/cache/util/RedisLock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package top.cadecode.uniboot.common.core.util;
1+
package top.cadecode.uniboot.common.plugin.cache.util;
22

33
import lombok.AllArgsConstructor;
44
import lombok.Data;

common/core/src/main/java/top/cadecode/uniboot/common/core/util/RedisUtil.java renamed to common/plugin/cache/src/main/java/top/cadecode/uniboot/common/plugin/cache/util/RedisUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package top.cadecode.uniboot.common.core.util;
1+
package top.cadecode.uniboot.common.plugin.cache.util;
22

33
import com.fasterxml.jackson.core.type.TypeReference;
44
import org.springframework.beans.factory.InitializingBean;
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.data.redis.core.StringRedisTemplate;
77
import org.springframework.stereotype.Component;
8+
import top.cadecode.uniboot.common.core.util.JacksonUtil;
89

910
import java.util.Objects;
1011
import java.util.concurrent.TimeUnit;

framework/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@
3333
<groupId>top.cadecode</groupId>
3434
<artifactId>uni-boot-common-plugin-datasource</artifactId>
3535
</dependency>
36+
<dependency>
37+
<groupId>top.cadecode</groupId>
38+
<artifactId>uni-boot-common-plugin-cache</artifactId>
39+
</dependency>
3640
</dependencies>
3741
</project>

framework/src/main/java/top/cadecode/uniboot/framework/security/filter/RedisTokenAuthFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
66
import org.springframework.stereotype.Component;
77
import top.cadecode.uniboot.common.core.consts.CacheKeyPrefix;
8-
import top.cadecode.uniboot.common.core.datasource.CacheKeyGenerator;
98
import top.cadecode.uniboot.common.core.enums.AuthModelEnum;
109
import top.cadecode.uniboot.common.core.enums.error.AuthErrorEnum;
11-
import top.cadecode.uniboot.common.core.util.RedisUtil;
10+
import top.cadecode.uniboot.common.plugin.cache.util.CacheKeyGenerator;
11+
import top.cadecode.uniboot.common.plugin.cache.util.RedisUtil;
1212
import top.cadecode.uniboot.framework.bean.dto.SysUserDto;
1313
import top.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto;
1414
import top.cadecode.uniboot.framework.security.TokenAuthFilter;

framework/src/main/java/top/cadecode/uniboot/framework/security/handler/RedisLoginSuccessHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import org.springframework.security.core.Authentication;
55
import org.springframework.stereotype.Component;
66
import top.cadecode.uniboot.common.core.consts.CacheKeyPrefix;
7-
import top.cadecode.uniboot.common.core.datasource.CacheKeyGenerator;
87
import top.cadecode.uniboot.common.core.enums.AuthModelEnum;
98
import top.cadecode.uniboot.common.core.response.ApiResult;
10-
import top.cadecode.uniboot.common.core.util.RedisUtil;
9+
import top.cadecode.uniboot.common.plugin.cache.util.CacheKeyGenerator;
10+
import top.cadecode.uniboot.common.plugin.cache.util.RedisUtil;
1111
import top.cadecode.uniboot.framework.bean.dto.SysUserDto;
1212
import top.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto;
1313
import top.cadecode.uniboot.framework.config.SecurityConfig;

0 commit comments

Comments
 (0)