/// <summary>
        /// 清除缓存
        /// </summary>
        /// <param name="pids"></param>
        /// <returns></returns>
        public async Task <bool> RemoveCache(List <string> pids)
        {
            var result = false;

            try
            {
                using (var client = new Service.BaoYang.CacheClient())
                {
                    var batchSize = 200;
                    for (var i = 0; i < Math.Ceiling(pids.Count * 1.0 / batchSize); i++) //分批清除缓存 每批次200个
                    {
                        var clientResult = await client.RemoveByTypeAsync
                                               ("BatteryCouponPriceDisplay", pids.Skip(i *batchSize).Take(batchSize).ToList());

                        result = clientResult.Success;
                        if (!result && clientResult.Exception != null)
                        {
                            Logger.Warn("调用BaoYang服务RemoveByTypeAsync失败", clientResult.Exception);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("RemoveCache", ex);
            }
            return(result);
        }
예제 #2
0
 public bool RemoveCache(IEnumerable <string> keys)
 {
     using (var client = new Service.BaoYang.CacheClient())
     {
         var serviceResult = client.Remove(keys);
         return(serviceResult.Result);
     }
 }
예제 #3
0
        /// <summary>
        /// 根据type和data清除缓存
        /// </summary>
        /// <param name="type"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <bool> RemoveCacheByTypeAsync(string type, List <string> data)
        {
            using (var cilent = new Service.BaoYang.CacheClient())
            {
                var cacheResult = await cilent.RemoveByTypeAsync(type, data);

                return(cacheResult.Success);
            }
        }
예제 #4
0
 public void UpdateFixedActivityCache(Guid activityId)
 {
     try
     {
         using (var client = new Service.BaoYang.CacheClient())
         {
             var getResult = client.UpdateFixedActivityCache(activityId);
             if (!getResult.Success && getResult != null)
             {
                 throw getResult.Exception;
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex);
     }
 }