Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
a016a8f0
Commit
a016a8f0
authored
Jul 29, 2021
by
张辰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://47.100.44.39:10001/tp-backend/tanpu-community
into dev
parents
c1faad0a
7cb189b4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
CacheConfig.java
...src/main/java/com/tanpu/community/config/CacheConfig.java
+1
-3
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+13
-5
No files found.
community-service/src/main/java/com/tanpu/community/config/CacheConfig.java
View file @
a016a8f0
...
@@ -3,12 +3,10 @@ package com.tanpu.community.config;
...
@@ -3,12 +3,10 @@ package com.tanpu.community.config;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.util.SpringUtils
;
import
com.tanpu.community.util.SpringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.cache.caffeine.CaffeineCacheManager
;
import
org.springframework.cache.caffeine.CaffeineCacheManager
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.Resource
;
import
java.util.Arrays
;
import
java.util.Arrays
;
@Configuration
@Configuration
...
@@ -19,7 +17,7 @@ public class CacheConfig {
...
@@ -19,7 +17,7 @@ public class CacheConfig {
@Bean
@Bean
public
RedisCache
redisCache
()
{
public
RedisCache
redisCache
()
{
return
new
RedisCache
.
Builder
().
cacheName
(
"
redis
"
).
build
();
return
new
RedisCache
.
Builder
().
cacheName
(
"
community2
"
).
build
();
}
}
@Bean
@Bean
...
...
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
a016a8f0
...
@@ -42,8 +42,8 @@ public class CommentService {
...
@@ -42,8 +42,8 @@ public class CommentService {
commentEntity
.
setCommentId
(
uuidGenHelper
.
getUuidStr
());
commentEntity
.
setCommentId
(
uuidGenHelper
.
getUuidStr
());
commentMapper
.
insert
(
commentEntity
);
commentMapper
.
insert
(
commentEntity
);
//失效缓存
//失效缓存
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_COMMENT_THEMEID
,
commentEntity
.
getThemeId
()
));
evictThemeCache
(
commentEntity
.
getThemeId
(
));
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_THEME_ID
,
commentEntity
.
getThemeId
()));
}
}
...
@@ -125,7 +125,9 @@ public class CommentService {
...
@@ -125,7 +125,9 @@ public class CommentService {
}
}
commentEntity
.
setReportStatus
(
ReportStatusEnum
.
REPORTED
.
getCode
());
commentEntity
.
setReportStatus
(
ReportStatusEnum
.
REPORTED
.
getCode
());
commentMapper
.
updateById
(
commentEntity
);
commentMapper
.
updateById
(
commentEntity
);
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CAHCE_COMMENT_ID
,
commentId
));
//失效缓存
evictThemeCache
(
commentEntity
.
getThemeId
());
}
}
//删除评论
//删除评论
...
@@ -137,8 +139,14 @@ public class CommentService {
...
@@ -137,8 +139,14 @@ public class CommentService {
}
}
commentEntity
.
setDeleteTag
(
DeleteTagEnum
.
DELETED
.
getCode
());
commentEntity
.
setDeleteTag
(
DeleteTagEnum
.
DELETED
.
getCode
());
commentMapper
.
updateById
(
commentEntity
);
commentMapper
.
updateById
(
commentEntity
);
//删除主题的评论列表缓存
//失效缓存
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CAHCE_COMMENT_ID
,
commentEntity
.
getThemeId
()));
evictThemeCache
(
commentEntity
.
getThemeId
());
}
// 失效关联主题缓存
private
void
evictThemeCache
(
String
themeId
){
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_COMMENT_THEMEID
,
themeId
));
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_THEME_ID
,
themeId
));
}
}
}
}
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