Commit 27a8a5c2 by 仲光辉

style: do some style.

parent 612a46be
...@@ -179,7 +179,7 @@ etc. ...@@ -179,7 +179,7 @@ etc.
.builder(connectionFactory) .builder(connectionFactory)
.cacheDefaults( .cacheDefaults(
RedisCacheConfiguration.defaultCacheConfig() RedisCacheConfiguration.defaultCacheConfig()
//缓存时间绝对过期时间20s //缓存时间绝对过期时间120s
.entryTtl(Duration.ofSeconds(120))) .entryTtl(Duration.ofSeconds(120)))
.transactionAware() .transactionAware()
.build(); .build();
......
...@@ -48,7 +48,7 @@ public class SpringCacheConfig { ...@@ -48,7 +48,7 @@ public class SpringCacheConfig {
.builder(connectionFactory) .builder(connectionFactory)
.cacheDefaults( .cacheDefaults(
RedisCacheConfiguration.defaultCacheConfig() RedisCacheConfiguration.defaultCacheConfig()
//缓存时间绝对过期时间20s //缓存时间绝对过期时间120s
.entryTtl(Duration.ofSeconds(120))) .entryTtl(Duration.ofSeconds(120)))
.transactionAware() .transactionAware()
.build(); .build();
......
...@@ -15,7 +15,6 @@ import org.redisson.api.RedissonClient; ...@@ -15,7 +15,6 @@ import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -302,7 +301,7 @@ public class RedisCacheAspect { ...@@ -302,7 +301,7 @@ public class RedisCacheAspect {
if (redisCache.dynamicDistributedLockKey()) { if (redisCache.dynamicDistributedLockKey()) {
// 动态分布式锁的 key // 动态分布式锁的 key
String dynamicDistributedLockKeyPattern = redisCache.dynamicDistributedLockKeyPattern(); String dynamicDistributedLockKeyPattern = redisCache.dynamicDistributedLockKeyPattern();
if (StringUtils.isEmpty(dynamicDistributedLockKeyPattern)) { if (StrUtil.isBlank(dynamicDistributedLockKeyPattern)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"使用 动态的分布式锁key(dynamicDistributedLockKey=ture),但是未指定 dynamicDistributedLockKeyPattern"); "使用 动态的分布式锁key(dynamicDistributedLockKey=ture),但是未指定 dynamicDistributedLockKeyPattern");
} }
...@@ -320,7 +319,7 @@ public class RedisCacheAspect { ...@@ -320,7 +319,7 @@ public class RedisCacheAspect {
} else { } else {
// 直接 指定 分布式锁的 key // 直接 指定 分布式锁的 key
distributedLockKey = redisCache.distributedLockKey(); distributedLockKey = redisCache.distributedLockKey();
if (StringUtils.isEmpty(distributedLockKey)) { if (StrUtil.isBlank(distributedLockKey)) {
throw new IllegalStateException( throw new IllegalStateException(
"未使用 动态的分布式锁key(dynamicDistributedLockKey=false),但是未指定 distributedLockKey"); "未使用 动态的分布式锁key(dynamicDistributedLockKey=false),但是未指定 distributedLockKey");
} }
...@@ -374,7 +373,7 @@ public class RedisCacheAspect { ...@@ -374,7 +373,7 @@ public class RedisCacheAspect {
} }
// 动态 缓存key // 动态 缓存key
String dynamicCacheKeyPattern = redisCache.dynamicCacheKeyPattern(); String dynamicCacheKeyPattern = redisCache.dynamicCacheKeyPattern();
if (StringUtils.isEmpty(dynamicCacheKeyPattern)) { if (StrUtil.isBlank(dynamicCacheKeyPattern)) {
throw new IllegalStateException("使用动态缓存key. 但是尚未配置 动态key pattern(dynamicCacheKeyPattern)"); throw new IllegalStateException("使用动态缓存key. 但是尚未配置 动态key pattern(dynamicCacheKeyPattern)");
} }
if (!dynamicCacheKeyPattern.contains(HUTOOL_FORMAT_PLACE_HOLDER)) { if (!dynamicCacheKeyPattern.contains(HUTOOL_FORMAT_PLACE_HOLDER)) {
...@@ -390,7 +389,7 @@ public class RedisCacheAspect { ...@@ -390,7 +389,7 @@ public class RedisCacheAspect {
} else { } else {
// 使用指定的 cache key // 使用指定的 cache key
cacheKey = redisCache.cacheKey(); cacheKey = redisCache.cacheKey();
if (StringUtils.isEmpty(cacheKey)) { if (StrUtil.isBlank(cacheKey)) {
throw new IllegalStateException("未使用动态缓存key,但是亦为指定 cacheKey"); throw new IllegalStateException("未使用动态缓存key,但是亦为指定 cacheKey");
} }
} }
...@@ -485,7 +484,7 @@ public class RedisCacheAspect { ...@@ -485,7 +484,7 @@ public class RedisCacheAspect {
// 获取数据 redis 的 String数据类型: key,value 都是JSON 字符串 // 获取数据 redis 的 String数据类型: key,value 都是JSON 字符串
String cache = stringRedisTemplate.opsForValue().get(key); String cache = stringRedisTemplate.opsForValue().get(key);
// 命中缓存 // 命中缓存
if (!StringUtils.isEmpty(cache)) { if (StrUtil.isNotBlank(cache)) {
// 有数据 ,则将数据进行转化 // 有数据 ,则将数据进行转化
return gson.fromJson(cache, TypeUtil.getReturnType(signature.getMethod())); return gson.fromJson(cache, TypeUtil.getReturnType(signature.getMethod()));
} }
...@@ -501,7 +500,7 @@ public class RedisCacheAspect { ...@@ -501,7 +500,7 @@ public class RedisCacheAspect {
while ((System.currentTimeMillis() - startMs) <= spinTryTimeInSecond * THOUSANDS_OF_ONE) { while ((System.currentTimeMillis() - startMs) <= spinTryTimeInSecond * THOUSANDS_OF_ONE) {
String cacheContent = stringRedisTemplate.opsForValue().get(key); String cacheContent = stringRedisTemplate.opsForValue().get(key);
// 命中缓存 // 命中缓存
if (!StringUtils.isEmpty(cacheContent)) { if (StrUtil.isNotBlank(cacheContent)) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("{} 调用方法 {} 现在 成功获取到缓存数据", Thread.currentThread().getName(), signature.getName()); log.debug("{} 调用方法 {} 现在 成功获取到缓存数据", Thread.currentThread().getName(), signature.getName());
} }
......
...@@ -139,6 +139,7 @@ public class IProvincesServiceImpl extends ServiceImpl<ProvincesMapper, Province ...@@ -139,6 +139,7 @@ public class IProvincesServiceImpl extends ServiceImpl<ProvincesMapper, Province
@CacheEvict(cacheNames = "provinces_detail_cache", key = "#provinces.provinceId") @CacheEvict(cacheNames = "provinces_detail_cache", key = "#provinces.provinceId")
@Override @Override
public Optional<Integer> updateProvinces(Provinces provinces) { public Optional<Integer> updateProvinces(Provinces provinces) {
LambdaQueryWrapper<Provinces> provincesLambdaQueryWrapper = new LambdaQueryWrapper<Provinces>() LambdaQueryWrapper<Provinces> provincesLambdaQueryWrapper = new LambdaQueryWrapper<Provinces>()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment