private void BaseContainerBag_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var containerBag = (IBaseContainerBag)sender; var mqKey = LimeMessageQueue.GenerateKey("ContainerBag", sender.GetType(), containerBag.Key, "UpdateContainerBag"); //获取对应Container的缓存相关 //加入消息列队,每过一段时间进行自动更新,防止属性连续被编辑,短时间内反复更新缓存。 LimeMessageQueue mq = new LimeMessageQueue(); mq.Add(mqKey, () => { var containerCacheStragegy = CacheStrategyFactory.GetContainerCacheStragegyInstance(); var cacheKey = ContainerHelper.GetCacheKey(this.GetType()); containerBag.CacheTime = DateTime.Now;//记录缓存时间 containerCacheStragegy.UpdateContainerBag(cacheKey, containerBag); }); }
/// <summary> /// 获取缓存Key /// </summary> /// <returns></returns> public static string GetCacheKey() { return(ContainerHelper.GetCacheKey(typeof(TBag))); }