Skip to content

Commit 31c6bd5

Browse files
committed
refactor: bean 名称修改
1 parent b648d20 commit 31c6bd5

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public class CacheConfig {
2727
*
2828
* @return CaffeineCacheManager 实例
2929
*/
30-
@Bean("localCache5s")
31-
public CacheManager localCache5s() {
30+
@Bean
31+
public CacheManager caffeine5s() {
3232
CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager();
3333
// 过期时间设置为 5 s
3434
caffeineCacheManager.setCaffeine(Caffeine.newBuilder()

framework/src/main/java/top/cadecode/uniboot/framework/config/RetryConfig.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.springframework.context.annotation.Bean;
44
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.context.annotation.Primary;
56
import org.springframework.retry.annotation.EnableRetry;
67
import org.springframework.retry.backoff.ExponentialBackOffPolicy;
78
import org.springframework.retry.policy.SimpleRetryPolicy;
@@ -17,8 +18,12 @@
1718
@Configuration
1819
public class RetryConfig {
1920

21+
/**
22+
* 重试模板,重试三次
23+
*/
24+
@Primary
2025
@Bean
21-
public RetryTemplate defaultRetryTemplate() {
26+
public RetryTemplate retryTemplate3Times() {
2227
RetryTemplate retryTemplate = new RetryTemplate();
2328
SimpleRetryPolicy simpleRetryPolicy = new SimpleRetryPolicy();
2429
simpleRetryPolicy.setMaxAttempts(3);

framework/src/main/java/top/cadecode/uniboot/framework/serviceimpl/SysApiServiceImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ public class SysApiServiceImpl extends ServiceImpl<SysApiMapper, SysApi> impleme
3131

3232
private final SysApiMapper sysApiMapper;
3333

34-
@Cacheable(cacheNames = KeyPrefix.API_ROLES, cacheManager = "localCache5s")
34+
@Cacheable(cacheNames = KeyPrefix.API_ROLES, cacheManager = "caffeine5s")
3535
@Override
3636
public List<SysApiRolesVo> listRolesVo() {
37-
List<SysApiRolesVo> sysApiRolesVos = RedisUtil.get(KeyPrefix.API_ROLES, new TypeReference<List<SysApiRolesVo>>() {});
37+
List<SysApiRolesVo> sysApiRolesVos = RedisUtil.get(KeyPrefix.API_ROLES, new TypeReference<List<SysApiRolesVo>>() {
38+
});
3839
if (ObjectUtil.isNotNull(sysApiRolesVos)) {
3940
return sysApiRolesVos;
4041
}
4142
synchronized (this) {
42-
sysApiRolesVos = RedisUtil.get(KeyPrefix.API_ROLES, new TypeReference<List<SysApiRolesVo>>() {});
43+
sysApiRolesVos = RedisUtil.get(KeyPrefix.API_ROLES, new TypeReference<List<SysApiRolesVo>>() {
44+
});
4345
if (ObjectUtil.isNotNull(sysApiRolesVos)) {
4446
return sysApiRolesVos;
4547
}

0 commit comments

Comments
 (0)