/// <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); }
public bool RemoveCache(IEnumerable <string> keys) { using (var client = new Service.BaoYang.CacheClient()) { var serviceResult = client.Remove(keys); return(serviceResult.Result); } }
/// <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); } }
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); } }