Commit 2cdded30 by ping.wu

购物车redis缓存失效时间7天

parent 37be0ad6
...@@ -133,6 +133,8 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService { ...@@ -133,6 +133,8 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
.filter(k -> StringUtils.isNotEmpty(k.getCartGoodsUid())) .filter(k -> StringUtils.isNotEmpty(k.getCartGoodsUid()))
.collect(Collectors.toMap(CartGoods::getCartGoodsUid, Function.identity(), (k1, k2) -> k1)); .collect(Collectors.toMap(CartGoods::getCartGoodsUid, Function.identity(), (k1, k2) -> k1));
operations.putAll(cartGoodsMap); operations.putAll(cartGoodsMap);
long expire =7;
operations.expire(expire, TimeUnit.DAYS);
return CartResponseUtil.success(); return CartResponseUtil.success();
} catch (Exception e) { } catch (Exception e) {
ErrorLog.printErrorLog("assortment-shoppingcart-sdk", trackingNo, e.getMessage(), "setCartGoodsList", cartParamDto, e, Level.ERROR); ErrorLog.printErrorLog("assortment-shoppingcart-sdk", trackingNo, e.getMessage(), "setCartGoodsList", cartParamDto, e, Level.ERROR);
...@@ -165,6 +167,8 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService { ...@@ -165,6 +167,8 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
redisTemplate.delete(redisKey); redisTemplate.delete(redisKey);
BoundValueOperations<String, String> operations = redisTemplate.boundValueOps(redisKey); BoundValueOperations<String, String> operations = redisTemplate.boundValueOps(redisKey);
operations.set(cartParamDto.getCouponCode()); operations.set(cartParamDto.getCouponCode());
long expire =7;
operations.expire(expire, TimeUnit.DAYS);
return CartResponseUtil.success(); return CartResponseUtil.success();
} catch (Exception e) { } catch (Exception e) {
ErrorLog.printErrorLog("assortment-shoppingcart-sdk", trackingNo, e.getMessage(), "setCartCouponCode", cartParamDto, e, Level.ERROR); ErrorLog.printErrorLog("assortment-shoppingcart-sdk", trackingNo, e.getMessage(), "setCartCouponCode", cartParamDto, e, Level.ERROR);
......
...@@ -80,6 +80,8 @@ public class ShoppingCartMallBaseServiceImpl implements ShoppingCartBaseService ...@@ -80,6 +80,8 @@ public class ShoppingCartMallBaseServiceImpl implements ShoppingCartBaseService
.filter(k -> StringUtils.isNotEmpty(k.getCartGoodsUid())) .filter(k -> StringUtils.isNotEmpty(k.getCartGoodsUid()))
.collect(Collectors.toMap(CartGoods::getCartGoodsUid, Function.identity(), (k1, k2) -> k1)); .collect(Collectors.toMap(CartGoods::getCartGoodsUid, Function.identity(), (k1, k2) -> k1));
operations.putAll(cartGoodsMap); operations.putAll(cartGoodsMap);
long expire =7;
operations.expire(expire, TimeUnit.DAYS);
return this.getCartGoodsList(cartParamDto, trackingNo); return this.getCartGoodsList(cartParamDto, trackingNo);
} catch (Exception e) { } catch (Exception e) {
ErrorLog.printErrorLog("assortment-shoppingcart-sdk", trackingNo, e.getMessage(), "setCartGoodsList", cartParamDto, e, Level.ERROR); ErrorLog.printErrorLog("assortment-shoppingcart-sdk", trackingNo, e.getMessage(), "setCartGoodsList", cartParamDto, e, Level.ERROR);
...@@ -113,6 +115,8 @@ public class ShoppingCartMallBaseServiceImpl implements ShoppingCartBaseService ...@@ -113,6 +115,8 @@ public class ShoppingCartMallBaseServiceImpl implements ShoppingCartBaseService
} else { } else {
cartGoods.setQty(cartParamDto.getQty()); cartGoods.setQty(cartParamDto.getQty());
operations.put(cartParamDto.getCartGoodsUid(), cartGoods); operations.put(cartParamDto.getCartGoodsUid(), cartGoods);
long expire =7;
operations.expire(expire, TimeUnit.DAYS);
} }
} }
return this.getCartGoodsList(cartParamDto, trackingNo); return this.getCartGoodsList(cartParamDto, trackingNo);
......
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