/// <summary> /// 刷新缓存 /// </summary> /// <param name="aid"></param> /// <param name="needLog"></param> /// <param name="activityType"></param> /// <returns></returns> public static bool ReflashActivityCache(Guid aid, bool needLog, int activityType) { try { var result = true; if (activityType == 1 || activityType == 3) { using (var client = new Service.Activity.CacheClient()) { var cacheresult = client.RefreshRedisCachePrefixForCommon(new RefreshCachePrefixRequest() { Prefix = "SecondKillPrefix", ClientName = "FlashSale", Expiration = TimeSpan.FromDays(1) }); cacheresult.ThrowIfException(true); result = cacheresult.Result; } } using (var client = new FlashSaleClient()) { var result1 = client.UpdateFlashSaleDataToCouchBaseByActivityID(aid); //初始化缓存数据 var result2 = client.RefreshFlashSaleHashCount(new List <string> { aid.ToString() }, false); //刷新活动页固化下来的数据 var activityExists = DALQiangGou.FetchActivityPageContentByActivityId(aid.ToString()); if (activityExists != null && activityExists.Any()) { foreach (var activityExist in activityExists) { using (var actclient = new ActivityClient()) { var activityId = actclient.GetOrSetActivityPageSortedPids(new SortedPidsRequest { Brand = activityExist.Brand, ProductType = (ProductType)activityExist.ProductType, NeedUpdatePkid = activityExist.Pkid, DicActivityId = new KeyValuePair <string, ActivityIdType>(aid.ToString(), ActivityIdType.FlashSaleActivity) }); var refresh = actclient.RefreshActivePageListModelCache(new ActivtyPageRequest { Channel = "wap", HashKey = activityExist.HashKey, }); } } } if (needLog) { var oprLog = new FlashSaleProductOprLog(); oprLog.OperateUser = ThreadIdentity.Operator.Name; oprLog.CreateDateTime = DateTime.Now; oprLog.BeforeValue = JsonConvert.SerializeObject(new { actvityid = aid }); oprLog.AfterValue = JsonConvert.SerializeObject(new { actvityid = aid }); oprLog.LogType = "FlashSaleLog"; oprLog.LogId = aid.ToString(); oprLog.Operation = "刷新缓存"; LoggerManager.InsertLog("FlashSaleOprLog", oprLog); } result1.ThrowIfException(true); result2.ThrowIfException(true); return(result1.Result && result2.Result && result); } } catch (Exception ex) { throw ex; } }