| @@ -231,6 +231,7 @@ public class WxCouponController extends BaseController { | |||||
| CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId(),null); | CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId(),null); | ||||
| CouponCacheUtils.removeOnlyCouponCache(redisTemplate, wxCoupon.getId()); | CouponCacheUtils.removeOnlyCouponCache(redisTemplate, wxCoupon.getId()); | ||||
| CouponCacheUtils.removeOldDetailCache(redisTemplate); | CouponCacheUtils.removeOldDetailCache(redisTemplate); | ||||
| CouponCacheUtils.removeOldDetailHtmlCache(redisTemplate); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -624,7 +624,8 @@ public class WxCouponController extends BaseController { | |||||
| boolean hasKey = cdRedisTemplate.hasKey(key); | boolean hasKey = cdRedisTemplate.hasKey(key); | ||||
| if (hasKey) { | if (hasKey) { | ||||
| // 从缓存获取用户信息 | // 从缓存获取用户信息 | ||||
| WxCouponCVo wxCouponCVo = operations.get(key); | |||||
| //WxCouponCVo wxCouponCVo = operations.get(key); | |||||
| WxCouponCVo wxCouponCVo = CouponCacheUtils.getOldDetailHtmlCache(redisTemplate, couponChannelIdL, couponIdL); | |||||
| return new ResultData(wxCouponCVo); | return new ResultData(wxCouponCVo); | ||||
| } | } | ||||
| WxCouponCVo wxCouponCVo = null; | WxCouponCVo wxCouponCVo = null; | ||||
| @@ -639,7 +640,8 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| // 插入缓存 | // 插入缓存 | ||||
| operations.set(key, wxCouponCVo, 3600, TimeUnit.SECONDS); | |||||
| //operations.set(key, wxCouponCVo, 3600, TimeUnit.SECONDS); | |||||
| CouponCacheUtils.setOldDetaileHtmlCache(redisTemplate, wxCouponCVo, couponChannelIdL, couponIdL); | |||||
| return new ResultData(wxCouponCVo); | return new ResultData(wxCouponCVo); | ||||
| } | } | ||||
| @@ -17,7 +17,8 @@ public enum EnumCacheKey { | |||||
| TOPIC_LIST(6, "topiList_"), | TOPIC_LIST(6, "topiList_"), | ||||
| COUPON_CHANNEL_STOCK(7, "couponChannelStock:couponChannelStock_"), | COUPON_CHANNEL_STOCK(7, "couponChannelStock:couponChannelStock_"), | ||||
| DOUYIN_LIVE_PAGE_LIST(8,"douyinLiveList"), | DOUYIN_LIVE_PAGE_LIST(8,"douyinLiveList"), | ||||
| OLD_DETAIL(9,"cc:") | |||||
| OLD_DETAIL(9,"cc:"), | |||||
| OLD_DETAIL_HTML(10,"ch:") | |||||
| ; | ; | ||||
| private static Map<Integer,EnumCacheKey> map = new HashMap<Integer,EnumCacheKey>(); | private static Map<Integer,EnumCacheKey> map = new HashMap<Integer,EnumCacheKey>(); | ||||
| static { | static { | ||||
| @@ -157,4 +157,29 @@ public class CouponCacheUtils { | |||||
| return RedisCacheUtils.getCacheObject(template, key,WxCouponCVo.class); | return RedisCacheUtils.getCacheObject(template, key,WxCouponCVo.class); | ||||
| } | } | ||||
| public static void removeOldDetailHtmlCache(RedisTemplate<String, Object> template) { | |||||
| String key = EnumCacheKey.OLD_DETAIL_HTML.getMessage(); | |||||
| RedisCacheUtils.removeCachePrefix(template, key); | |||||
| } | |||||
| public static void setOldDetaileHtmlCache(RedisTemplate<String, Object> template,WxCouponCVo coupon,Long couponChannelIdL,Long couponIdL) { | |||||
| String key = EnumCacheKey.OLD_DETAIL_HTML.getMessage(); | |||||
| if(couponChannelIdL > 0){ | |||||
| key = key + couponChannelIdL; | |||||
| }else if(couponIdL > 0){ | |||||
| key = key + couponIdL; | |||||
| } | |||||
| RedisCacheUtils.cache(template, key, coupon, 3600); | |||||
| } | |||||
| public static WxCouponCVo getOldDetailHtmlCache(RedisTemplate<String, Object> template,Long couponChannelIdL,Long couponIdL) { | |||||
| String key = EnumCacheKey.OLD_DETAIL_HTML.getMessage(); | |||||
| if(couponChannelIdL > 0){ | |||||
| key = key + couponChannelIdL; | |||||
| }else if(couponIdL > 0){ | |||||
| key = key + couponIdL; | |||||
| } | |||||
| return RedisCacheUtils.getCacheObject(template, key,WxCouponCVo.class); | |||||
| } | |||||
| } | } | ||||