Commit 31dd5ed1 authored by 邓吉芬's avatar 邓吉芬

修改商品缓存

parent 5f4d77c5
......@@ -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;
}
}
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