Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dankal-share-cache
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
仲光辉
dankal-share-cache
Commits
27a8a5c2
Commit
27a8a5c2
authored
Mar 27, 2021
by
仲光辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: do some style.
parent
612a46be
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
9 deletions
+9
-9
README.md
README.md
+1
-1
SpringCacheConfig.java
.../java/cn/dankal/share/cache/config/SpringCacheConfig.java
+1
-1
RedisCacheAspect.java
.../dankal/share/cache/reference/cache/RedisCacheAspect.java
+6
-7
IProvincesServiceImpl.java
...ankal/share/cache/service/impl/IProvincesServiceImpl.java
+1
-0
No files found.
README.md
View file @
27a8a5c2
...
...
@@ -179,7 +179,7 @@ etc.
.
builder
(
connectionFactory
)
.
cacheDefaults
(
RedisCacheConfiguration
.
defaultCacheConfig
()
//缓存时间绝对过期时间20s
//缓存时间绝对过期时间
1
20s
.
entryTtl
(
Duration
.
ofSeconds
(
120
)))
.
transactionAware
()
.
build
();
...
...
src/main/java/cn/dankal/share/cache/config/SpringCacheConfig.java
View file @
27a8a5c2
...
...
@@ -48,7 +48,7 @@ public class SpringCacheConfig {
.
builder
(
connectionFactory
)
.
cacheDefaults
(
RedisCacheConfiguration
.
defaultCacheConfig
()
//缓存时间绝对过期时间20s
//缓存时间绝对过期时间
1
20s
.
entryTtl
(
Duration
.
ofSeconds
(
120
)))
.
transactionAware
()
.
build
();
...
...
src/main/java/cn/dankal/share/cache/reference/cache/RedisCacheAspect.java
View file @
27a8a5c2
...
...
@@ -15,7 +15,6 @@ import org.redisson.api.RedissonClient;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
...
...
@@ -302,7 +301,7 @@ public class RedisCacheAspect {
if
(
redisCache
.
dynamicDistributedLockKey
())
{
// 动态分布式锁的 key
String
dynamicDistributedLockKeyPattern
=
redisCache
.
dynamicDistributedLockKeyPattern
();
if
(
Str
ingUtils
.
isEmpty
(
dynamicDistributedLockKeyPattern
))
{
if
(
Str
Util
.
isBlank
(
dynamicDistributedLockKeyPattern
))
{
throw
new
IllegalArgumentException
(
"使用 动态的分布式锁key(dynamicDistributedLockKey=ture),但是未指定 dynamicDistributedLockKeyPattern"
);
}
...
...
@@ -320,7 +319,7 @@ public class RedisCacheAspect {
}
else
{
// 直接 指定 分布式锁的 key
distributedLockKey
=
redisCache
.
distributedLockKey
();
if
(
Str
ingUtils
.
isEmpty
(
distributedLockKey
))
{
if
(
Str
Util
.
isBlank
(
distributedLockKey
))
{
throw
new
IllegalStateException
(
"未使用 动态的分布式锁key(dynamicDistributedLockKey=false),但是未指定 distributedLockKey"
);
}
...
...
@@ -374,7 +373,7 @@ public class RedisCacheAspect {
}
// 动态 缓存key
String
dynamicCacheKeyPattern
=
redisCache
.
dynamicCacheKeyPattern
();
if
(
Str
ingUtils
.
isEmpty
(
dynamicCacheKeyPattern
))
{
if
(
Str
Util
.
isBlank
(
dynamicCacheKeyPattern
))
{
throw
new
IllegalStateException
(
"使用动态缓存key. 但是尚未配置 动态key pattern(dynamicCacheKeyPattern)"
);
}
if
(!
dynamicCacheKeyPattern
.
contains
(
HUTOOL_FORMAT_PLACE_HOLDER
))
{
...
...
@@ -390,7 +389,7 @@ public class RedisCacheAspect {
}
else
{
// 使用指定的 cache key
cacheKey
=
redisCache
.
cacheKey
();
if
(
Str
ingUtils
.
isEmpty
(
cacheKey
))
{
if
(
Str
Util
.
isBlank
(
cacheKey
))
{
throw
new
IllegalStateException
(
"未使用动态缓存key,但是亦为指定 cacheKey"
);
}
}
...
...
@@ -485,7 +484,7 @@ public class RedisCacheAspect {
// 获取数据 redis 的 String数据类型: key,value 都是JSON 字符串
String
cache
=
stringRedisTemplate
.
opsForValue
().
get
(
key
);
// 命中缓存
if
(
!
StringUtils
.
isEmpty
(
cache
))
{
if
(
StrUtil
.
isNotBlank
(
cache
))
{
// 有数据 ,则将数据进行转化
return
gson
.
fromJson
(
cache
,
TypeUtil
.
getReturnType
(
signature
.
getMethod
()));
}
...
...
@@ -501,7 +500,7 @@ public class RedisCacheAspect {
while
((
System
.
currentTimeMillis
()
-
startMs
)
<=
spinTryTimeInSecond
*
THOUSANDS_OF_ONE
)
{
String
cacheContent
=
stringRedisTemplate
.
opsForValue
().
get
(
key
);
// 命中缓存
if
(
!
StringUtils
.
isEmpty
(
cacheContent
))
{
if
(
StrUtil
.
isNotBlank
(
cacheContent
))
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"{} 调用方法 {} 现在 成功获取到缓存数据"
,
Thread
.
currentThread
().
getName
(),
signature
.
getName
());
}
...
...
src/main/java/cn/dankal/share/cache/service/impl/IProvincesServiceImpl.java
View file @
27a8a5c2
...
...
@@ -139,6 +139,7 @@ public class IProvincesServiceImpl extends ServiceImpl<ProvincesMapper, Province
@CacheEvict
(
cacheNames
=
"provinces_detail_cache"
,
key
=
"#provinces.provinceId"
)
@Override
public
Optional
<
Integer
>
updateProvinces
(
Provinces
provinces
)
{
LambdaQueryWrapper
<
Provinces
>
provincesLambdaQueryWrapper
=
new
LambdaQueryWrapper
<
Provinces
>()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment