Exemple #1
0
 /// <summary>
 /// 释放,开始立即更新所有缓存
 /// </summary>
 public void Dispose()
 {
     if (DoFlush)
     {
         WlMessageQueue.OperateQueue();
     }
 }
Exemple #2
0
 /// <summary>
 /// 启动线程轮询
 /// </summary>
 public void Run()
 {
     do
     {
         WlMessageQueue.OperateQueue();
         Thread.Sleep(_sleepMilliSeconds);
     } while (true);
 }
Exemple #3
0
        private void BaseContainerBag_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var containerBag = (IBaseContainerBag)sender;
            var mqKey        = WlMessageQueue.GenerateKey("ContainerBag", sender.GetType(), containerBag.Key, "UpdateContainerBag");

            //加入消息队列,每过一段时间进行自动更新,防止属性连续被编辑,短时间内反复更新缓存。
            WlMessageQueue mq = new WlMessageQueue();

            mq.Add(mqKey, () =>
            {
                //var containerCacheStrategy = CacheStrategyFactory.GetContainerCacheStrategyInstance();
                var containerCacheStrategy = CacheStrategyFactory.GetObjectCacheStrategyInstance().ContainerCacheStrategy;
                var itemCacheKey           = ContainerHelper.GetItemCacheKey(containerBag);
                containerBag.CacheTime     = DateTime.Now;//记录缓存时间

                //cacheKey形如:Container:Com.Alibaba.MP.Containers.AccessTokenBag:wx669ef95216eef885
                containerCacheStrategy.UpdateContainerBag(itemCacheKey, containerBag);
            });
        }