Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
draw
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
draw
draw
Commits
31dd5ed1
Commit
31dd5ed1
authored
Oct 26, 2022
by
邓吉芬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改商品缓存
parent
5f4d77c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
ActivityGoodsServiceImpl.java
.../com/miya/draw/service/impl/ActivityGoodsServiceImpl.java
+5
-4
No files found.
src/main/java/com/miya/draw/service/impl/ActivityGoodsServiceImpl.java
View file @
31dd5ed1
...
...
@@ -45,7 +45,7 @@ public class ActivityGoodsServiceImpl extends ServiceImpl<ActivityGoodsMapper, A
public
List
<
String
>
listAllActivityGoods
(
Long
activityId
)
{
List
<
String
>
goodList
=
new
ArrayList
<>();
try
{
Object
object
=
redisTemplate
.
opsForValue
().
get
(
buildKey
());
Object
object
=
redisTemplate
.
opsForValue
().
get
(
buildKey
(
activityId
));
if
(
Objects
.
nonNull
(
object
))
{
return
(
List
<
String
>)
object
;
}
...
...
@@ -59,7 +59,7 @@ public class ActivityGoodsServiceImpl extends ServiceImpl<ActivityGoodsMapper, A
if
(
CollectionUtils
.
isNotEmpty
(
activityGoodsList
))
{
goodList
=
activityGoodsList
.
stream
().
map
(
ActivityGoods:
:
getCode
).
collect
(
Collectors
.
toList
());
try
{
redisTemplate
.
opsForValue
().
setIfAbsent
(
buildKey
(),
goodList
,
Duration
.
ofHours
(
1
));
redisTemplate
.
opsForValue
().
setIfAbsent
(
buildKey
(
activityId
),
goodList
,
Duration
.
ofHours
(
1
));
}
catch
(
Exception
e
)
{
log
.
error
(
"往缓存储存活动商品错误: {} ,继续执行操作"
,
e
.
getMessage
());
}
...
...
@@ -73,7 +73,8 @@ public class ActivityGoodsServiceImpl extends ServiceImpl<ActivityGoodsMapper, A
*
* @return
*/
private
String
buildKey
()
{
return
ConStants
.
SHIZU_DRAW_PREFIX
+
ConStants
.
SHIZU_ACTIVITY_GOOD
;
private
String
buildKey
(
Long
activityId
)
{
//shizu:draw:activity:good
return
ConStants
.
SHIZU_DRAW_PREFIX
+
ConStants
.
SHIZU_ACTIVITY_GOOD
+
":"
+
activityId
;
}
}
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